Created
October 6, 2020 22:46
-
-
Save timuruski/d67ab57642ea444c93566ecda60f54b6 to your computer and use it in GitHub Desktop.
This file contains 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 beep(a, b) | |
result = "" | |
result += a.to_s | |
if a && b | |
result += " and " | |
end | |
result += b.to_s | |
end | |
puts beep("foo", "bar") | |
puts beep("foo", nil) | |
puts beep(nil, "bar") | |
puts "---" | |
def boop(a, b) | |
[a, b].compact.join(" and ") | |
end | |
puts boop("foo", "bar") | |
puts boop("foo", nil) | |
puts boop(nil, "bar") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment