Skip to content

Instantly share code, notes, and snippets.

@rubyisbeautiful
Created February 9, 2022 21:28
Show Gist options
  • Save rubyisbeautiful/197dd75d37ef1a23652535ca4b0f5a0d to your computer and use it in GitHub Desktop.
Save rubyisbeautiful/197dd75d37ef1a23652535ca4b0f5a0d to your computer and use it in GitHub Desktop.
Test conditional logic with/without parens
#!/usr/bin/env ruby
def is_foo(foo='bar')
foo == 'foo'
end
def is_bar(foo='bar')
foo == 'bar'
end
should_build1 = false
should_build2 = false
git_branch = ARGV[0]
unless is_foo git_branch || is_bar(git_branch)
should_build1 = true
end
puts "old way: #{should_build1}"
unless is_foo(git_branch) || is_bar(git_branch)
should_build2 = true
end
puts "new way: #{should_build2}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment