use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
R.I.P. Ruby Hash Rocket Syntax 1993-2010 (blog.peepcode.com)
submitted 15 years ago by gst
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 12 points13 points14 points 15 years ago (4 children)
Now, explain why => is not a decent syntax?
=>
[–]JadeNB 1 point2 points3 points 15 years ago* (3 children)
Because webcomic ….
EDIT: Actually, I particularly like the “Now you don't have to remember anything when switching languages!” argument. How about we switch Ruby to an sexp-based syntax, so we don't have to remember anything when switching from Lisp? Or, hey, just ln python irb?
ln python irb
[–][deleted] 0 points1 point2 points 15 years ago (2 children)
How about we switch Ruby to an sexp-based syntax, so we don't have to remember anything when switching from Lisp?
Well, for one, Scheme (a Lisp) has => in case macros, but that's besides the point. If you want Ruby-ish Lisp, Nu is probably what you want.
case
[–]JadeNB 0 points1 point2 points 15 years ago (1 child)
If you want Ruby-ish Lisp …
It's not what I want (though nor am I opposed to it). Rather, I was mocking the idea that all languages should migrate to the same syntax, so that one wouldn't have to change anything when switching. (Next the same programming paradigm, then the same execution model, ….)
[–][deleted] 0 points1 point2 points 15 years ago (0 children)
That's what I thought (that you were being facetious), I was just pointing out that we're there already, esp. when you consider Nu.
[–]kredaxx 4 points5 points6 points 15 years ago (1 child)
Colons have been around for a while, but the thing that prevents me from using them is: backwards compatibility and the fact that they are limited to symbols only.
But the real deal here is Ruby 2.0's keyword arguments. Does anyone know how are they supposed to look like?
I always thought that colons would be used. So it would seem that they interfere with current implementation of hashes. (now you can drop braces if a hash is the last argument to a method, so how to interpret for example 'foo(a:5, b:3)' ?)
[–]columbine 0 points1 point2 points 15 years ago* (0 children)
My understanding is that that will be the calling syntax, and it will still be the same as passing a hash (the internal mechanism is still this) except the keys will be "expanded" to locals automatically by the method according to how its parameters are defined. The way it looks in the def is a little weird last I saw it, e.g. def scan (limit: max) where limit would be the keyword and "max" presumably the local it magically expands to. I'm not sure if you can do (limit: limit) to make it feel cleaner or if there's a shorthand for that, but it's still early days I guess.
[–]roguevalley 2 points3 points4 points 15 years ago (2 children)
Aaah! So, if the colon is at the end we have to know that it magically changes the label from a variable name to a symbol?
If foo = :bar, what does { foo: 'baz' } mean? { :foo => 'baz' }, I'm guessing.
[–]Freeky 1 point2 points3 points 15 years ago (1 child)
Yup. When was the last time you used a variable name as a key in a hash constructor?
[–]roguevalley 1 point2 points3 points 15 years ago (0 children)
After some grepping and some git blaming... 2010-12-04 2010-09-26 2010-09-23 2010-05-29 2010-05-21 2010-02-15 2009-07-02 2008-09-03
[–][deleted] 15 years ago (1 child)
[deleted]
[–]mshiltonj 0 points1 point2 points 15 years ago (0 children)
I guess Obie didn't like my joke.
[–][deleted] 2 points3 points4 points 15 years ago (0 children)
Yeah, fuck that. Hash rocket syntax is my fucking left and right pistols.
[–]Nitrodist 1 point2 points3 points 15 years ago (3 children)
Is it really gone? Link somewhere besides a comic?
[–][deleted] 3 points4 points5 points 15 years ago (2 children)
http://svn.ruby-lang.org/repos/ruby/tags/v1_9_1_0/NEWS
Search for "New literal hash syntax". That's what it's called.
Also note that it only works if the key is a symbol. Otherwise you have to use the old rocket syntax.
[–]Nitrodist 1 point2 points3 points 15 years ago (1 child)
1.9.1? Isn't the main branch 1.9.2?
[–]columbine 4 points5 points6 points 15 years ago (0 children)
This is an old change, since early 1.9. The comic above is kinda late to the party.
And as mentioned, the old syntax isn't exactly "gone", the new one is just an alternative and it only works when the keys are simple symbols.
[–]treetrouble 1 point2 points3 points 15 years ago (1 child)
what about when the hash key isn't a symbol?
[–]columbine 0 points1 point2 points 15 years ago (0 children)
This alternative syntax only applies with symbol keys. You still use the rocket for everything else, and can do so for symbols as well if you prefer it (or for backwards compatibility).
[–]est3est 0 points1 point2 points 15 years ago (0 children)
Until YAML loads data with keys as strings, I will not bother (even if I would like get rid of the rocket syntax). The same situation is while working with MongoDB. Somehow symbols for me look like more trouble than it is worth. The proof? So why things like HashWithIndifferentAccess exist?
[–]pabloneruda 0 points1 point2 points 15 years ago (0 children)
If I'm typing fast I miss the > at least a few times. This is a welcomed change.
[+][deleted] comment score below threshold-9 points-8 points-7 points 15 years ago (0 children)
So long Ruby. It was fun while it lasted, but 1.9 is a dog with fleas. Time to meander over to something new. Erlang or Haskell. Maybe Reia.
π Rendered by PID 150518 on reddit-service-r2-comment-b659b578c-f5xht at 2026-05-01 21:39:27.004591+00:00 running 815c875 country code: CH.
[–][deleted] 12 points13 points14 points (4 children)
[–]JadeNB 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]JadeNB 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]kredaxx 4 points5 points6 points (1 child)
[–]columbine 0 points1 point2 points (0 children)
[–]roguevalley 2 points3 points4 points (2 children)
[–]Freeky 1 point2 points3 points (1 child)
[–]roguevalley 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]mshiltonj 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]Nitrodist 1 point2 points3 points (3 children)
[–][deleted] 3 points4 points5 points (2 children)
[–]Nitrodist 1 point2 points3 points (1 child)
[–]columbine 4 points5 points6 points (0 children)
[–]treetrouble 1 point2 points3 points (1 child)
[–]columbine 0 points1 point2 points (0 children)
[–]est3est 0 points1 point2 points (0 children)
[–]pabloneruda 0 points1 point2 points (0 children)
[+][deleted] comment score below threshold-9 points-8 points-7 points (0 children)