Closed bachpx195 closed 3 years ago
Truyền nhiều biến vào method với *agrument
def what_up(greeting, *bros)
bros.each { |bro| puts "#{greeting}, #{bro}!" }
end
what_up("What up", "Justin", "Ben", "Kevin Sorbo")
What up, Justin! What up, Ben! What up, Kevin Sorbo! ["Justin", "Ben", "Kevin Sorbo"]
print "Who are you?"
user_input = gets.chomp
user_input.downcase!
if user_input.include? "s"
user_input.gsub!(/s/,"th")
end
Who are you? bachs "bachth"
Array.new(4) { rand(1...9) }
My favorite language
link