diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2019-07-29 12:27:48 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2019-07-29 12:28:36 -0300 |
commit | 17b8cde6d16cee9a7b7d5daf1ef79d8facfcfbf6 (patch) | |
tree | c37e77e5eebdaf82c5bfc282135f117bf7bc60f3 /activesupport | |
parent | 2e6d9af6c8b9900481dabfca685b3e335c2f27aa (diff) | |
download | rails-17b8cde6d16cee9a7b7d5daf1ef79d8facfcfbf6.tar.gz rails-17b8cde6d16cee9a7b7d5daf1ef79d8facfcfbf6.tar.bz2 rails-17b8cde6d16cee9a7b7d5daf1ef79d8facfcfbf6.zip |
Call raise with parentheses like a normal method call with arguments
Using `(raise FooError, "error")` is like forcing a "new scope" around
the `raise` call, it's simpler to just wrap the `raise` arguments with
parentheses just like any other method call would.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/access.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb index 1a0b10b4f6..f6a14c08bc 100644 --- a/activesupport/lib/active_support/core_ext/string/access.rb +++ b/activesupport/lib/active_support/core_ext/string/access.rb @@ -76,7 +76,7 @@ class String # str.first(0) # => "" # str.first(6) # => "hello" def first(limit = 1) - self[0, limit] || (raise ArgumentError, "negative limit") + self[0, limit] || raise(ArgumentError, "negative limit") end # Returns the last character of the string. If a limit is supplied, returns a substring @@ -90,6 +90,6 @@ class String # str.last(0) # => "" # str.last(6) # => "hello" def last(limit = 1) - self[[length - limit, 0].max, limit] || (raise ArgumentError, "negative limit") + self[[length - limit, 0].max, limit] || raise(ArgumentError, "negative limit") end end |