We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
headius
Learn more about funding links in repositories.
Report abuse
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting SyntaxError: (irb):4: syntax error, unexpected kIF_MOD when assigning hash key the value of an if expression.
SyntaxError: (irb):4: syntax error, unexpected kIF_MOD
if
Here is the code I am pasting in:
@something = Hash.new @d = { type: if @something.is_a?(Hash) 'hash' elsif @something.is_a?(Array) 'array' else 'unknown' end, foo: "bar" } puts @d
** Jruby 1.7.19 **
Code pasted into jruby 1.7.9 rib.
rvm use jruby-1.7.19 do irb jruby-1.7.19 :001 > @something = Hash.new => {} jruby-1.7.19 :002 > jruby-1.7.19 :003 > @d = { jruby-1.7.19 :004 > type: if @something.is_a?(Hash) jruby-1.7.19 :005?> 'hash' jruby-1.7.19 :006?> elsif @something.is_a?(Array) jruby-1.7.19 :007?> 'array' jruby-1.7.19 :008?> else jruby-1.7.19 :009 > 'unknown' jruby-1.7.19 :010?> end, jruby-1.7.19 :011 > foo: "bar" jruby-1.7.19 :012?> } => {:type=>"hash", :foo=>"bar"} jruby-1.7.19 :013 > jruby-1.7.19 :014 > puts @d {:type=>"hash", :foo=>"bar"} => nil
** jruby-9.0.0.0.pre2 **
Same code pasted into jruby-9.0.0.0.pre2 irb.
rvm use jruby-9.0.0.0.pre2 do irb jruby-9.0.0.0.pre2 :001 > @something = Hash.new => {} jruby-9.0.0.0.pre2 :002 > jruby-9.0.0.0.pre2 :003 > @d = { jruby-9.0.0.0.pre2 :004 > type: if @something.is_a?(Hash) jruby-9.0.0.0.pre2 :005?> 'hash' jruby-9.0.0.0.pre2 :006?> elsif @something.is_a?(Array) jruby-9.0.0.0.pre2 :007?> 'array' jruby-9.0.0.0.pre2 :008?> else jruby-9.0.0.0.pre2 :009 > 'unknown' jruby-9.0.0.0.pre2 :010?> end, jruby-9.0.0.0.pre2 :011 > foo: "bar" jruby-9.0.0.0.pre2 :012?> } SyntaxError: (irb):4: syntax error, unexpected kIF_MOD type: if @something.is_a?(Hash) from org/jruby/RubyKernel.java:1005:in `eval' from org/jruby/RubyKernel.java:1315:in `loop' from org/jruby/RubyKernel.java:1125:in `catch' from org/jruby/RubyKernel.java:1125:in `catch' from /Users/deverly/.rvm/rubies/jruby-9.0.0.0.pre2/bin/irb:13:in `<top>' jruby-9.0.0.0.pre2 :013 > jruby-9.0.0.0.pre2 :014 > puts @d => nil
The text was updated successfully, but these errors were encountered:
Works as expected on 9.1.9.0:
irb(main):001:0> @something = Hash.new => {} irb(main):002:0> irb(main):003:0* @d = { irb(main):004:1* type: if @something.is_a?(Hash) irb(main):005:2> 'hash' irb(main):006:2> elsif @something.is_a?(Array) irb(main):007:2> 'array' irb(main):008:2> else irb(main):009:2* 'unknown' irb(main):010:2> end, irb(main):011:1* foo: "bar" irb(main):012:1> } => {:type=>"hash", :foo=>"bar"} irb(main):013:0> irb(main):014:0* puts @d {:type=>"hash", :foo=>"bar"} => nil
Sorry, something went wrong.
Thanks for the update!
No branches or pull requests
Getting
SyntaxError: (irb):4: syntax error, unexpected kIF_MOD
when assigning hash key the value of anif
expression.Here is the code I am pasting in:
** Jruby 1.7.19 **
Code pasted into jruby 1.7.9 rib.
** jruby-9.0.0.0.pre2 **
Same code pasted into jruby-9.0.0.0.pre2 irb.
The text was updated successfully, but these errors were encountered: