Re: Trying to understand method calls in a class body. Fundamentally, why doesn't this work?

Good morning

On Fri, Dec 05, 2014 at 08:46:48PM -0500, Jorge C. wrote:

Ok. That makes sense. Out of pure curiosity, is there any “hacky” way to call
instance methods in a class context?


class Thing
def initialize()
puts “baeh”
end

def do_something(arg = nil)
puts "Doo! " << arg.to_s
end

def self::do_it()
Thing.new().do_something(‘Did it!’)
end
end

dumbly overwrite the previous class-definition

class Thing
Thing.new().do_something
end

or explicitly call a method on the defined class

Thing::do_it

On Dec 6, 2014, at 00:59, Michael U. [email protected]
wrote:

dumbly overwrite the previous class-definition

class Thing
Thing.new().do_something
end

This doesn’t overwrite anything, nor is it dumb. It is just reopening a
class.

Ryan D. wrote in post #1164175:

This doesn’t overwrite anything, nor is it dumb. It is just reopening a
class.

Can we call this a linguistics-problem. I still think that I have
answered the original question. Why the subject-line is prefixed with
‘Re:’ as in the mailing-list may or may not be another problem of mine,
not of the original poster.