Skip to content

Instantly share code, notes, and snippets.

@joequery
Created January 28, 2012 17:06
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 joequery/1695043 to your computer and use it in GitHub Desktop.
Save joequery/1695043 to your computer and use it in GitHub Desktop.
Ruby Assignment Returns
1.9.2-p290 :001 > def mytest
1.9.2-p290 :002?> return @someval = 10
1.9.2-p290 :003?> end
=> nil
1.9.2-p290 :004 > mytest
=> 10
1.9.2-p290 :005 > @someval
=> 10
1.9.2-p290 :006 > def mytest2
1.9.2-p290 :007?> return @someval ||= 30
1.9.2-p290 :008?> end
=> nil
1.9.2-p290 :009 > mytest2
=> 10
1.9.2-p290 :010 > @someval
=> 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment