# What are all the ways to output a string in Ruby? def hello_ruby greet = "Hello Ruby!" print greet, "\n" puts greet print greet, "\n" puts greet $stdout.write greet + "\n" $stdout.puts greet $stdout.print greet, "\n" $stdout << greet + "\n" (greet+"\n").chars {|c| print c} end
- # What are all the ways to output a string in Ruby?
- def hello_ruby
- greet = "Hello Ruby!"
- print greet, "\n"
- puts greet
print "#{greet}"puts "Hello Ruby!"- print greet, "
- "
- puts greet
- $stdout.write greet + "\n"
- $stdout.puts greet
- $stdout.print greet, "\n"
- $stdout << greet + "\n"
(greet+"").each_char {|c| print c}- (greet+"
- ").chars {|c| print c}
- end