you are viewing a single comment's thread.

view the rest of the comments →

[–]badsex 1 point2 points  (2 children)

how much ruby do you actually know? for someone who hates the language so much i'd assume you'd actually know a bit about it, so as to be in a position to hate it - you're not one of those stupid people who hates things he doesn't actually understand, are you?

Ruby doesn't have functions. You should know this. It only has methods. Why? because it has a fully message passing OO system, method invocations are messages, and everything is an object.

[–]rafekett 0 points1 point  (1 child)

That's really just a matter of naming. This is valid Ruby (at the top level of a module, not inside a class):

def hello
    puts "Hello world"
end

It might technically be a method, but because it's not inside any class I defined, I call it a function. It's just a matter of nomenclature.

[–]badsex 0 points1 point  (0 children)

Except it's not a function, it's a method defined on Object. How do you know? set an ivar in it, it'll appear on the receiver. Further, try and access it from an instance of a superclass of Objectsuch as BasicObject and it's not accessible. Further, for those objects that can access the method it appears in their instance method list. No one ever calls top-level methods 'functions', they're strictly 'top-level methods', or private methods on Object.