Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created October 27, 2016 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3452a0521988f3836ea1e4e7b362a958 to your computer and use it in GitHub Desktop.
Save anonymous/3452a0521988f3836ea1e4e7b362a958 to your computer and use it in GitHub Desktop.
# In the tutorial https://www.tutorialspoint.com/ruby/ruby_syntax.htm
# there is a quote:
# Whitespace characters such as spaces and tabs are generally ignored in Ruby code,
# except when they appear in strings. Sometimes, however, they are used to interpret
# ambiguous statements. Interpretations of this sort produce warnings when the -w
# option is enabled.
# Example:
# a + b is interpreted as a+b ( Here a is a local variable)
# a +b is interpreted as a(+b) ( Here a is a method call)
# However, this program prints out "3\n3\n" instead of crashing when trying to apply
# a to the value positive b. So there must be more to it than that, right?
a = 1
b = 2
c = a + b
# I do get a warning for this next line, however it parses it the same as the previous.
d = a +b
puts c
puts d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment