Commit

ca4d57e

Should do this more often: go through the PRs of an OSS project and look at the changes proposed/dismissed. Besides seeing what's coming in the new release ⭐️, I always learn a thing or two. Take e.g. the recent changes to ActiveSupport (https://github.com/rails/rails/pulls?q=is%3Apr+state%3Aclosed+label%3Aactivesupport) and finding that this actually works (i.e. no_bar is seen as defined):
ruby
def foo(bar: (no_bar = true))
  puts "Using #{no_bar ? 'no ' : ''}bar"
end
Alternatively you'd use a sentinel:
ruby
NO_BAR = Object.new.freeze

def foo(bar: NO_BAR)
  puts "Using #{NO_BAR.equal?(bar) ? 'no ' : ''}bar"
end
GitHubPull requests · rails/railsRuby on Rails. Contribute to rails/rails development by creating an account on GitHub.

commit ca4d57e