Skip to content

Instantly share code, notes, and snippets.

@eternal44
Created August 19, 2015 22:36
Show Gist options
  • Save eternal44/78996b4c9343691bb22f to your computer and use it in GitHub Desktop.
Save eternal44/78996b4c9343691bb22f to your computer and use it in GitHub Desktop.
Lambda vs Method
def query_leap_year(year)
year % 400 == 0 || year % 100 != 0 && year % 4 == 0
end
def year_in_minutes(year)
60 * 24 * (query_leap_year(year) ? 366 : 365)
end
##########
# VERSUS #
##########
query_leap_year = ->(year) do
year % 400 == 0 || year % 100 != 0 && year % 4 == 0
end
year_in_minutes = ->(year) do
60 * 24 * (query_leap_year.call(year) ? 366 : 365)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment