You hardly ever have to use the word true
in your code.
if (something == true)
# do something cool
end
Can be rewritten as
if something
# do something cool
end
Same goes with false
if (something == false)
# do something cool
end
Can be rewritten as
if !something
# do something cool
end
Or
unless something
# do something cool
end
Similarly, methods that return booleans
def even?
if x % 2 == 0
return true
else
return false
end
end
Can be rewritten as
def even?
x % 2 == 0
end