Created
August 5, 2017 03:29
-
-
Save KrauseFx/e2cac9c00d03423838b064049e737d95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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