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

Fix useless operator warnings #1660

Closed
wants to merge 1 commit into from
Closed

Conversation

pocke
Copy link
Member

@pocke pocke commented Jun 23, 2017

Forwardable._valid_method? warns about useless operator when it is received an operator such as * and +.

$ RUBYOPT='-w' ruby -rforwardable -e 'Forwardable._valid_method?(:*)'
<compiled>: warning: possibly useless use of * in void context

This behavior is problematic when a delegator is defined for an operator.
For example:

require 'forwardable'

class A
  extend Forwardable

  def s
    's'
  end

  def_delegator :s, :* # <compiled>: warning: possibly useless use of * in void context
end

p(A.new * 10) # => "ssssssssss"

`Forwardable._valid_method?` warns about useless operator when it is received an operator such as `*` and `+`.

```bash
$ RUBYOPT='-w' ruby -rforwardable -e 'Forwardable._valid_method?(:*)'
<compiled>: warning: possibly useless use of * in void context
```

This behavior is problematic when a delegator is defined for an operator.
For example:

```ruby
require 'forwardable'

class A
  extend Forwardable

  def s
    's'
  end

  def_delegator :s, :* # <compiled>: warning: possibly useless use of * in void context
end

p(A.new * 10) # => "ssssssssss"
```
@matzbot matzbot closed this in af4ba5c Jun 23, 2017
@pocke pocke deleted the warning-forwardable branch June 23, 2017 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant