Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use block variable instead of global #20486

Merged
merged 1 commit into from
Jun 9, 2015

Commits on Jun 9, 2015

  1. Use block variable instead of global

    ```ruby
    Benchmark.ips do |x|
      x.report("$&") {
        "foo".gsub(/f/) { $&.hex }
      }
      x.report("block var") {
        "foo".gsub(/f/) { |match| match.hex }
      }
    end
    ```
    
    ```
    Calculating -------------------------------------
                      $&    23.271k i/100ms
               block var    24.804k i/100ms
    -------------------------------------------------
                      $&    321.981k (± 7.4%) i/s -      1.606M
               block var    324.949k (± 9.2%) i/s -      1.612M
    ```
    repinel committed Jun 9, 2015
    Configuration menu
    Copy the full SHA
    b28b192 View commit details
    Browse the repository at this point in the history