Guest User

Untitled

a guest
Oct 27th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.79 KB | None | 0 0
  1. # In the tutorial https://www.tutorialspoint.com/ruby/ruby_syntax.htm
  2. # there is a quote:
  3.  
  4. # Whitespace characters such as spaces and tabs are generally ignored in Ruby code,
  5. # except when they appear in strings. Sometimes, however, they are used to interpret
  6. # ambiguous statements. Interpretations of this sort produce warnings when the -w
  7. # option is enabled.
  8. # Example:
  9. # a + b is interpreted as a+b ( Here a is a local variable)
  10. # a  +b is interpreted as a(+b) ( Here a is a method call)
  11.  
  12. # However, this program prints out "3\n3\n" instead of crashing when trying to apply
  13. # a to the value positive b. So there must be more to it than that, right?
  14.  
  15. a = 1
  16. b = 2
  17. c = a + b
  18. # I do get a warning for this next line, however it parses it the same as the previous.
  19. d = a +b
  20. puts c
  21. puts d
Add Comment
Please, Sign In to add comment