The Geekiest Hello World

english, geek, pat Add comments

Folks, I think that I have found (one of) the geekiest hello world out there. Implemented in Groovy using the dynamic interception of method calls. Here it goes:

class Hello {
  Object invokeMethod(String name, Object arguments) {
    System.out.println "hello $name!"
  }
}

def hello = new Hello()
hello.john()
hello.you()

Which produce the following output:

hello john!
hello you!

I suppose the same mechanism can be used with Ruby (and some other dynamic languages).

No Responses to “The Geekiest Hello World”

  1. BenP Says:

    Ha cool, my turn…

    class Hello:
    def __getattr__(self,name):
    print(\Hello \ + name + \!\)

    h = Hello()
    h.pat

    >> prints \Hello pat!\

  2. BenP Says:

    gah not formatted properly, but you get the gist… ;)

  3. pajai Says:

    Hi Ben!

    hey, that’s cool your version in Python.

    Cheers!

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in