There is a shorter way to define class methods in Ruby using the class << self
syntax. Here's how you can rewrite your code using this syntax:
main.rb72 chars8 lines
This syntax allows you to define methods that can be called directly on the class itself, without the need for an instance of the class. So you can call Year.hi
to output "hi".
gistlibby LogSnag