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

Array::each works different than ruby #1457

Closed
jsaak opened this issue Sep 12, 2015 · 5 comments
Closed

Array::each works different than ruby #1457

jsaak opened this issue Sep 12, 2015 · 5 comments

Comments

@jsaak
Copy link

jsaak commented Sep 12, 2015

given this program

[[1,"A"],[2,"B"]].each do |a,b|
  puts a
  puts b
end
$ crystal test.cr
[1, "A"]

[2, "B"]

$ ruby test.cr   
1
A
2
B

i have not seen anywhere mentioning that this will work differently
i am not sure if this is a bug or intentional
(i would not miss this feature of ruby very much)

@jhass
Copy link
Member

jhass commented Sep 12, 2015

This is because Crystal has no autosplat. I'm closing this as a duplicate of #392 since it won't ever happen for nested arrays. Also related to #132

@jhass jhass closed this as completed Sep 12, 2015
@jsaak
Copy link
Author

jsaak commented Sep 12, 2015

please indicate somewhere in documentation , that this is the expected behaviour

@jhass
Copy link
Member

jhass commented Sep 12, 2015

I guess we should add it to https://github.com/manastech/crystal/wiki/Crystal-for-Rubyists

@jsaak
Copy link
Author

jsaak commented Sep 12, 2015

yup, no one else in the world would try this, only rubyists

@Nakilon
Copy link
Contributor

Nakilon commented Sep 13, 2015

Try what? Doesn't for i, j in a work in Python?

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

No branches or pull requests

3 participants