Skip to content
Related Articles

Related Articles

Ruby | Symbol empty? function
  • Last Updated : 10 Dec, 2019

Symbol#empty?() : empty?() is a Symbol class method which checks whether the symbol is empty.

Syntax: Symbol.empty?()

Parameter: Symbol values

Return: true – if symbol is empty otherwise return false

Example #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"


Output :

Symbol a : aBcDeF

Symbol b : äöü

Symbol c : ABCDEF



Symbol a empty? form : false

Symbol b empty? form : false

Symbol c empty? form : false

Example #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"


Output :

Symbol a : geeks

Symbol b : åöó

Symbol c : 



Symbol a empty? form : false

Symbol b empty? form : false

Symbol c empty? form : true

My Personal Notes arrow_drop_up
Recommended Articles
Page :