Skip to content

Instantly share code, notes, and snippets.

@sue445
Created September 13, 2013 01:26
Show Gist options
  • Save sue445/6545891 to your computer and use it in GitHub Desktop.
Save sue445/6545891 to your computer and use it in GitHub Desktop.
each_cons試してみた
1.9.3p194 :001 > (1..10).each_cons(3){|a, b, c| puts "#{a}, #{b}, #{c}" }
1, 2, 3
2, 3, 4
3, 4, 5
4, 5, 6
5, 6, 7
6, 7, 8
7, 8, 9
8, 9, 10
=> nil
1.9.3p194 :002 > (1..10).each_cons(3){|v| p v }
[1, 2, 3]
[2, 3, 4]
[3, 4, 5]
[4, 5, 6]
[5, 6, 7]
[6, 7, 8]
[7, 8, 9]
[8, 9, 10]
=> nil
@sue445
Copy link
Author

sue445 commented Sep 13, 2013

パーフェクトRubyには前者だけあって、るりまサーチには後者だけしか載ってなかった。

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