Skip to content

Instantly share code, notes, and snippets.

@sathish316
Created November 30, 2010 18:17
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 sathish316/722109 to your computer and use it in GitHub Desktop.
Save sathish316/722109 to your computer and use it in GitHub Desktop.
cadr.rb
class Array
def car
first
end
def cdr
self[1..-1]
end
def method_missing(method_id)
if method_id.to_s =~ /c([ad]*)([ad]{1})r/
self.send("c#{$2}r").send("c#{$1}r")
else
super
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment