You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the methods whose names end with ?, do you maybe want to test for nil rather than test to see if the variable is defined? That is, you want the method to return false if it is defined as nil, right?
For example:
def stream?
defined? @stream
end
Would this be better off as the following?:
def stream?
!! @stream
end
I use !! because I find it helpful for methods ending with ? to return true or false, rather than truthy or falsy values. I feel it is more precise, and produces clearer and more concise output when logging/debugging using expressions like puts "stream? == #{foo.stream?}".
The text was updated successfully, but these errors were encountered:
abrom
added a commit
to abrom/henkei
that referenced
this issue
May 10, 2017
For the methods whose names end with
?
, do you maybe want to test for nil rather than test to see if the variable is defined? That is, you want the method to return false if it is defined as nil, right?For example:
Would this be better off as the following?:
I use
!!
because I find it helpful for methods ending with?
to return true or false, rather than truthy or falsy values. I feel it is more precise, and produces clearer and more concise output when logging/debugging using expressions likeputs "stream? == #{foo.stream?}"
.The text was updated successfully, but these errors were encountered: