Making Sense of the Text

In The Book of Ruby, Ruby source code is written like this:

def saysomething
    puts( "Hello" )
end

Often the code will be annotated with comments. Ruby comments are any text following a hash mark (#) on a single line. The comments are ignored by the Ruby interpreter. When I want to draw attention to some output that Ruby displays or to a value returned by a piece of code (even if that value is not displayed), I indicate this with this type of comment: # =>. Occasionally, when I want to draw attention to some input that the user should enter, I use this type of comment: # <=. Here is an example to illustrate these commenting conventions:

puts("Enter a calculation:" ) # Prompt user this is a simple comment exp = gets().chomp() ...

Get The Book of Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.