Skip to content

Instantly share code, notes, and snippets.

@benwoody
Created June 30, 2011 21:52
Show Gist options
  • Save benwoody/1057361 to your computer and use it in GitHub Desktop.
Save benwoody/1057361 to your computer and use it in GitHub Desktop.
Ruby Liners
# Reversing a String
(0...(a.length/2)).each{|i| a[i], a[-i-1]=a[-i-1], a[i]}
return a
# Fibonacci Sequence
(0...n).inject([0, 1]) { |p, _| [p[1], p[0] + p[1]] }[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment