Use a Ruby method like a block or lambda
Sometimes you want to use a vanilla Ruby method like a block. You can use
foo_plus = "foo".method(:+) foo_plus.call("bar") # => "foobar"
The method reference also understands
#to_proc so you can feed it to block-taking methods by prefixing it with
printer = method(:puts) [1, 2, 3].each(&printer) # will print one line per number
Flaky tests are tests that sometimes fail for no obvious reason. They are the plague of many end-to-end (E2E) test suites that automate the browser through tools like Capybara and Selenium.
Join our free training event and learn to fix any flaky test suite, even in large legacy applications.