Static methods in ruby modules? -
Is it possible to declare stable methods in a module in Ruby?
Module software DEF Self.exit includes "exited" end end class Windows includes software DRF self.start "start" self.exit end and windows Start
The above example "Exits"
Is the example methods possible in the module?
Define your module in this way (i.e. an example in the exit
module Method):
Module software exits the DF exit "End" and end
and then Expand
Instead of include
class Windows extension software # Your own Start method, as the question is at the end
In use:
irb (main): 016: 0> Windows.start started = & gt; >
... Therefore when class is used in terms of definition (as a class itself as a receiver), methods become class methods.
Comments
Post a Comment