Definition of methods: self

In Why’s poignant guide to Ruby some examples appear where he defines a
class “class LotteryTicket”, and then he defines a method “def
self.new_random”, or “def…)”; that is, before the name
of the method, the name of the class appears (the name or the keyword
“self”). However, in other methods in the other classes, the class name
is not set before the name of the method. Explanations? :smiley:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs