0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ruby学習#15 Methods

Posted at

def sayhi
puts "Hello User"
end

sayhi

Hello User

puts "Top"
sayhi
puts "Bottom"

def sayhi(name,age)
puts ("Hello" + name + ",you are " + age)
end

sayhi("Mike",73)

error String型とInt型がくっつかない。
def sayhi(name,age)
puts ("Hello" + name + ",you are " + age.to_s)
end

sayhi("Mike",73)

Hello Mile ,you are 73

def sayhi(name="no name",age=-1)
puts ("Hello" + name + ",you are " + age.to_s)
end
sayhi("Mike")

Hello Mike, you are -1
sayhi
Hello no name , you are -1

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?