Here is a one-liner function that checks if a year is a leap year in Ruby:
main.rb81 chars4 linesThis function takes a year as input and returns true if it is a leap year, and false otherwise. It uses the ternary operator || to evaluate two conditions:
Note that this function assumes the year parameter is an integer. If you pass a non-integer value to this function, it may throw an error.
gistlibby LogSnag