Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# as this is used in the fastlane code base a lot, and lots of people ask about it
# .length method
"my string".length # => 9
"".length # => 0
nil.length # NoMethodError: undefined method `length' for nil:NilClass
# .to_s method
"my string".to_s # => "my string"
"".to_s # => ""
nil.to_s # => ""
nil.to_s == "".to_s# => true
# combine the 2
nil.to_s.length == 0 # => true
"".to_s.length == 0 # => true
"a".to_s.length == 0 # false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.