Skip to content

Instantly share code, notes, and snippets.

@jefflunt
Last active August 29, 2015 14:01
Show Gist options
  • Save jefflunt/c382083c7b8853974437 to your computer and use it in GitHub Desktop.
Save jefflunt/c382083c7b8853974437 to your computer and use it in GitHub Desktop.
Handling hashes
> text = 'some text'
=> "some text"
> hash_options = {rant_id:1,date:11/04/2014,top:text,number:12}
=> {:rant_id=>1, :date=>0, :top=>"some text", :number=>12}
NOTE that 'date' gets set to zero, because it's being interpreted as, "11 divided by 04 divided by 2014"
Also this:
> hash_options = rant_id:1,date:11/04/2014,top:text,number:12
SyntaxError: (irb):5: syntax error, unexpected tLABEL
hash_options = rant_id:1,date:11/04/2014,top:text,number:12
^
As opposed to this:
> hash_options = {rant_id:1,date:11/04/2014,top:text,number:12}
=> {:rant_id=>1, :date=>0, :top=>"some text", :number=>12}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment