stuff Flashcards
1
Q
what does !! mean?
A
Preceding a truthy object with a single bang ! will return false and preceding it with a double bang !! will return true:
a = “hello”
!a # => false
!!a # => true
The converse is true for falsey objects.
2
Q
puts vs p
A
For example: > puts "Ruby Is Cool" Ruby Is Cool > p "Ruby Is Cool" "Ruby Is Cool"
What is p useful for?
Debugging.
When you’re looking for things like (normally invisible) newline characters, or you want to make sure some value is correct, then you use p.
Another difference:
puts always returns nil p returns the object you pass to it
3
Q
truthy
A
Remember this rule: everything in Ruby is considered “truthy” except for false and nil.