On 06/23/2014 04:30 AM, Sylvain Joyeux wrote:
> I've been wanting to use -w ... However, I found out that quite a few
> high-profile gems out there are not clean under -w (e.g. pry), meaning
> that I have a hard time using -w myself.
>
> How many people actually *do* use -w ? Is this really a "best practice"
> in the ruby world these days ?

Here's one reason I avoid -w:

class PointOnTimeline
   def initialize time
     @t0 = time # might be Time or something else
   end

   def do_something_with_other_time time
     time < @t0 # fail fast if time and @t0 are not comparable
     return "something"
   end
end

The code is generic with respect to the objects used as times. We don't 
want to assert that they are Time instances, only that they can be compared.

However:

$ ruby -w t.rb
t.rb:7: warning: possibly useless use of < in void context

Yep, we called #< without using the result. So, what to do? Assign it to 
an unused local? That's a warning. Wrap it in `if ... end`? Ok, no 
warning, but that looks strange. Is there a missing `then` clause?

Maybe the best -w clean version is:

time.send(:<, @t0)

But that doesn't really make the intent clearer, and in fact it suggests 
a different intent: that we're trying to call a private method.