Created
August 19, 2015 22:36
-
-
Save eternal44/78996b4c9343691bb22f to your computer and use it in GitHub Desktop.
Lambda vs Method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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