mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
This commit is contained in:
parent
2e6d9af6c8
commit
17b8cde6d1
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue