Skip to content

Instantly share code, notes, and snippets.

@devn
Created February 17, 2012 02:00
Show Gist options
  • Select an option

  • Save devn/1849788 to your computer and use it in GitHub Desktop.

Select an option

Save devn/1849788 to your computer and use it in GitHub Desktop.
Your Very Own Object System
Point = -> (x, y) {
methods =
Hash[:x, -> { x },
:y, -> { Math.sqrt(x*x + y*y) },
:shift!, ->(xinc, yinc)
{ x += xinc
y += yinc }]
->(message, *args) { methods[message].(*args)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment