Skip to content
Related Articles

Related Articles

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

Symbol#size() : size() is a Symbol class method which returns the size/length of the symbol object.

Syntax: Symbol.size()

Parameter: Symbol values

Return: the size/length of the symbol object.

Example #1 :






# Ruby code for Symbol.size() 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"
  
  
# size form 
puts "Symbol a size form : #{a.size}\n\n"
puts "Symbol b size form : #{b.size}\n\n"
puts "Symbol c size form : #{c.size}\n\n"


Output :

Symbol a : aBcDeF

Symbol b : äöü

Symbol c : ABCDEF



Symbol a size form : 6

Symbol b size form : 3

Symbol c size form : 6

Example #2 :




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


Output :

Symbol a : geeks

Symbol b : åöó

Symbol c : GEEKS



Symbol a size form : 5

Symbol b size form : 3

Symbol c size form : 5

My Personal Notes arrow_drop_up
Recommended Articles
Page :