Mega Code Archive

 
Categories / Ruby / Class
 

Creating Class Methods

# Besides class variables, you can create class methods in Ruby.  # You can call a class method using just the name of the class.  class Mathematics   def Mathematics.add(operand_one, operand_two)     return operand_one + operand_two   end end puts "1 + 2 = " + Mathematics.add(1, 2).to_s