1.
" Hello "
This write "Hello" to the screen with a new line tailed to.
Print " Hello "
Just like puts, but without new line.
2.
" You know nothing ". Length
This output of the string length.
" Jon Snow ". Reverse
"Wons Noj"
" Overwatch " . Downcase #---> "overwatch" " Overwatch ". UpCase #--->" Overwatch "
Let ' s play overwatch ...
3.
# I ' m a single line comment! =beginwell,i am amultiple linecomment! =end
4.
Variable_name = Gets.chomp
gets is the Ruby method, which gets the input from the user. When getting input, Ruby automatically adds a blank line (or newline) after each bit of input; Chomp removes that extra line. (Your program would work fine without chomp, and you'll get extra blank lines everywhere.)
gets
Is the Ruby method thatgetsinput from the user. When getting input, Ruby automatically adds a blank line (orNewLine) after each bit of input; chomp
removes that extra line. (Your program would work fine withoutchomp
, but you'll get extra blank lines everywhere.)
<Ruby> Basics