Skip to content

Instantly share code, notes, and snippets.

@timuruski
Created October 6, 2020 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timuruski/d67ab57642ea444c93566ecda60f54b6 to your computer and use it in GitHub Desktop.
Save timuruski/d67ab57642ea444c93566ecda60f54b6 to your computer and use it in GitHub Desktop.
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