Skip to content
New issue

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

different behavior each_with_index.inject #3137

Closed
matsumotory opened this issue Mar 19, 2016 · 5 comments
Closed

different behavior each_with_index.inject #3137

matsumotory opened this issue Mar 19, 2016 · 5 comments

Comments

@matsumotory
Copy link
Member

Hi, @matz

each_with_index.inject of mruby is a different behavior with CRuby.

  • mruby
> ["a", "b", "c"].each_with_index.inject("d") { |a, (b, c)| p a, b, c }
"d"
["a", 0]
nil
"d"
["b", 1]
nil
"d"
["c", 2]
nil
 => "d"
  • CRuby
irb(main):006:0> ["a", "b", "c"].each_with_index.inject("d") { |a, (b, c)| p a, b, c }
"d"
"a"
0
["d", "a", 0]
"b"
1
[["d", "a", 0], "b", 1]
"c"
2
=> [[["d", "a", 0], "b", 1], "c", 2]
@matz
Copy link
Member

matz commented Mar 19, 2016

mruby does not support destructuring in assignment or block parameters yet. #2841

@matsumotory
Copy link
Member Author

Ah…sorry, Thank you for your pointer!

@matz
Copy link
Member

matz commented Mar 20, 2016

Sorry for leaving destructuring unimplemented.

@zzak
Copy link
Contributor

zzak commented Mar 20, 2016

@matz Is there a reason it's not implemented? Should we put it on the roadmap, or is there another limitation I'm missing?

@matz
Copy link
Member

matz commented Mar 20, 2016

It's difficult (but not impossible) to implement destructuring without adding new instruction (for the sake for compatibility).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants