📜  红宝石 |符号为空?函数

📅  最后修改于: 2022-05-13 01:54:19.888000             🧑  作者: Mango

红宝石 |符号为空?函数

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

示例 #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