Ian Bicking: the old part of his blog

Fixes whats wrong with python comment 000

Yes, I think that's mostly what he means. Also, you can add and override methods in the same way. You can change the class directly -- monkey patching -- or you can create an instance and assign a function to an instance variable to override the method that the class contains. Other uses of first-class functions can accomplish all sorts of things; though honestly how they do that in Ruby (generally) I'm not sure, since it doesn't have "functions" per se, just methods. I get the impression there's some confusion there, with a couple techniques available.
Comment on Re: Fixes What's Wrong With Python
by Ian Bicking


they just write:

def an_instance.amethod(args)

It is a nice way to write stuff since it also allows for clear specification of class/module methods:

class Foo
 # we are in Foo's scope, "self" is Foo
 def foo() puts "I'm an instance method" end
 def self.foo() puts "I'm a singleton method of a Class instance" end
 def self.bar() puts "In java parlance, I'm a static method of class Foo" end

(Formatting fixed; I'm not actually the author of this comment)

# Ian Bicking

There's also this:

module Mod
  def hello
    "Hello from Mod.\n"
class Klass
  def hello
    "Hello from Klass.\n"
k = Klass.new
k.hello       ->      "Hello from Klass.\n"
k.extend(Mod)         ->      #<Klass:0x4018d554>
k.hello       ->      "Hello from Mod.\n"
# Alexander Staubo