当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Ruby Symbol empty?用法及代码示例


Symbol#empty?():empty?()是Symbol类方法,它检查符号是否为空。

用法:Symbol.empty?()

参数:符号值


返回:true-如果符号为空,否则返回false

范例1:

# Ruby code for Symbol.empty?() method 
  
# declaring Symbol  
a = :aBcDeF
  
# declaring Symbol 
b =:"\u{e4 f6 fc}"
  
# declaring Symbol 
c =:ABCDEF
  
# Symbol  
puts "Symbol a:#{a}\n\n"
puts "Symbol b:#{b}\n\n"
puts "Symbol c:#{c}\n\n\n\n"
  
  
# empty? form  
puts "Symbol a empty? form:#{a.empty?}\n\n"
puts "Symbol b empty? form:#{b.empty?}\n\n"
puts "Symbol c empty? form:#{c.empty?}\n\n"

输出:

Symbol a:aBcDeF

Symbol b:äöü

Symbol c:ABCDEF



Symbol a empty? form:false

Symbol b empty? form:false

Symbol c empty? form:false

范例2:

# Ruby code for Symbol.empty?() method 
  
# declaring Symbol  
a = :geeks
  
# declaring Symbol 
b =:"\u{e5 f6 f3}"
  
# declaring Symbol 
c = ""
  
# Symbol  
puts "Symbol a:#{a}\n\n"
puts "Symbol b:#{b}\n\n"
puts "Symbol c:#{c}\n\n\n\n"
  
  
# empty? form  
puts "Symbol a empty? form:#{a.empty?}\n\n"
puts "Symbol b empty? form:#{b.empty?}\n\n"
puts "Symbol c empty? form:#{c.empty?}\n\n"

输出:

Symbol a:geeks

Symbol b:åöó

Symbol c:



Symbol a empty? form:false

Symbol b empty? form:false

Symbol c empty? form:true



相关用法


注:本文由纯净天空筛选整理自mayank5326大神的英文原创作品 Ruby | Symbol empty? function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。