Skip to content

Instantly share code, notes, and snippets.

@nevir
Created December 27, 2012 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nevir/4390714 to your computer and use it in GitHub Desktop.
Save nevir/4390714 to your computer and use it in GitHub Desktop.
Array#fetch...
irb(main):001:0> a = [11, 22, 33, 44]
=> [11, 22, 33, 44]
irb(main):002:0> a.fetch(0) { |i| i }
=> 11
irb(main):003:0> a.fetch(1) { |i| i }
=> 22
irb(main):004:0> a.fetch(2) { |i| i }
=> 33
irb(main):005:0> a.fetch(3) { |i| i }
=> 44
irb(main):006:0> a.fetch(4) { |i| i }
=> 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment