Skip to content

Instantly share code, notes, and snippets.

@chetan
Created August 22, 2013 19:08
Show Gist options
  • Save chetan/6311441 to your computer and use it in GitHub Desktop.
Save chetan/6311441 to your computer and use it in GitHub Desktop.
fun with ruby strings
ruby-2.0.0-p247 $ pry
[1] pry(main)> "foo" "bar"
=> "foobar"
[2] pry(main)> a = "foo"; b = "bar";
[3] pry(main)> a b
NoMethodError: undefined method `a' for main:Object
from (pry):3:in `__pry__'
[4] pry(main)> a "bar"
NoMethodError: undefined method `a' for main:Object
from (pry):4:in `__pry__'
[5] pry(main)> "foo" b
SyntaxError: unexpected tIDENTIFIER, expecting end-of-input
[5] pry(main)> puts(a b)
NoMethodError: undefined method `a' for main:Object
from (pry):5:in `__pry__'
[6] pry(main)> puts(a "bar")
NoMethodError: undefined method `a' for main:Object
from (pry):6:in `__pry__'
[7] pry(main)> puts("foo" b)
SyntaxError: unexpected tIDENTIFIER, expecting ')'
puts("foo" b)
^
[7] pry(main)> puts("foo" "bar")
foobar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment