Ruby | Symbol to_s function
Last Updated :
10 Dec, 2019
Symbol#to_s() : to_s() is a Symbol class method which returns string representation of the symbol object.
Syntax: Symbol.to_s()
Parameter: Symbol values
Return: string representation of the symbol object.
Example #1 :
a = :aBcDeF
b = : "\u{e4 f6 fc}"
c = : ABCDEF
puts "Symbol a to_s form : #{a.to_s}\n\n"
puts "Symbol b to_s form : #{b.to_s}\n\n"
puts "Symbol c to_s form : #{c.to_s}\n\n"
|
Output :
Symbol a to_s form : aBcDeF
Symbol b to_s form : äöü
Symbol c to_s form : ABCDEF
Example #2 :
a = :geeks
b = : "\u{e5 f6 f3}"
c = : GEEKS
puts "Symbol a to_s form : #{a.to_s}\n\n"
puts "Symbol b to_s form : #{b.to_s}\n\n"
puts "Symbol c to_s form : #{c.to_s}\n\n"
|
Output :
Symbol a to_s form : geeks
Symbol b to_s form : åöó
Symbol c to_s form : GEEKS
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...