在Ruby on Rails中对nil v。空v。空白的简要解释 - A concise explanation of nil v. empty v. blank in Ruby on Rails

问题:

I find myself repeatedly looking for a clear definition of the differences of nil? 我发现本身一再寻找nil?差别的明肯定义nil? , blank? blank? , and empty? empty? in Ruby on Rails. 在Ruby on Rails中。 Here's the closest I've come: 这是我最接近的: spa

  • blank? objects are false, empty, or a whitespace string. 对象是false,空或空白字符串。 For example, "" , " " , nil , [] , and {} are blank. 例如, """ "nil[]{}为空。 .net

  • nil? objects are instances of NilClass. 对象是NilClass的实例。 code

  • empty? objects are class-specific, and the definition varies from class to class. 对象是特定于类的,而且定义因类而异。 A string is empty if it has no characters, and an array is empty if it contains no items. 若是字符串没有字符,则该字符串为空;若是字符串不包含任何项目,则该字符串为空。 对象

Is there anything missing, or a tighter comparison that can be made? 有什么遗漏,或者能够作出更严格的比较吗? ci


解决方案:

参考一: https://stackoom.com/question/3iKs/在Ruby-on-Rails中对nil-v-空v-空白的简要解释
参考二: https://oldbug.net/q/3iKs/A-concise-explanation-of-nil-v-empty-v-blank-in-Ruby-on-Rails
相关文章
相关标签/搜索