Skip to content
Related Articles

Related Articles

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

Symbol#intern() : intern() is a Symbol class method which returns the object corresponding to symbol.

Syntax: Symbol.intern()

Parameter: Symbol values

Return: the object corresponding to symbol

Example #1 :






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


Output :

Symbol a intern form : aBcDeF

Symbol b intern form : äöü

Symbol c intern form : ABCDEF

Example #2 :




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


Output :

Symbol a intern form : geeks

Symbol b intern form : åöó

Symbol c intern form : GEEKS
My Personal Notes arrow_drop_up
Recommended Articles
Page :