Part 1: blank?
定义
- An object is blank if it is false, empty or a whitespace string
- for example: false, '', ' ', nil, [], and {} are all blank
- it will return boolean value: true or false, say true if blank, otherwise false
举例
Part 2: empty?
定义
- can be used to check empty string '', empty array [], empty hash {}
- an object isn't empty if it is a whitespace string
- it will return boolean value: true or false, say true if empty, otherwise false
- returns true if an collection is empty
举例
'', [], {} are empty
-
' ' isn't empty, because it has whitespace
-
false, nil can't use empty method
-
returns true is an collection is empty