Using this example from the documentation, results in error:
[“foo”, “bar”].to_h {|s| [s.ord, s]}
Traceback (most recent call last):
3: from /Volumes/Radha/Users/rob/.rvm/rubies/ruby-2.5.3/bin/irb:11:in <main>' 2: from (irb):37 1: from (irb):37:into_h’
TypeError (wrong element type String at 0 (expected array))
I have tried this on 2.6.0-preview 2 and 2.5.3.
Why am I getting this error?
and got: NameError (undefined local variable or method `“foo”’ for main:Object)
As a newbie, I’m not grokking this.
The example I gave was out of the documentation.
Is the documentation wrong?
What am I missing?
Read Benjamin’s blog article, but no further ahead.
Yes, understand it’s new, but, as I stated, I tested this with 2.6.0-preview2 and 2.5.3.
Again, my question is this: “Is the documentation incorrect or is there a bug?”
I understand your “safe” approach, but surely a documentation example should work?