Open In App
Related Articles

Ruby | StringIO bytes function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

StringIO#bytes() : bytes() is a StringIO class method which returns the value of bytes of the stringIO.

Syntax: StringIO.bytes() Parameter: StringIO values Return: value of bytes of the stringIO.

Example #1 : 

Ruby

# Ruby code for StringIO.bytes() method
 
# loading StringIO
require 'stringio'
 
# declaring StringIO
a = StringIO.new("geeksforgeeks")
 
 
# StringIO
puts "StringIO a : #{a.string}\n\n"
 
 
# bytes form
puts "StringIO a bytes form : #{a.bytes}\n\n"

                    

Output :

StringIO a : geeksforgeeks

StringIO a bytes form : #

Example #2 : 

Ruby

# Ruby code for StringIO.bytes() method
 
# loading StringIO
require 'stringio'
 
# declaring StringIO
a = StringIO.new("icancode")
 
# StringIO
puts "StringIO a : #{a.string}\n\n"
 
# bytes form
puts "StringIO a bytes form : #{a.bytes}\n\n"

                    

Output :

StringIO a : icancode

StringIO a bytes form : #

Note : The Enumerator value can change as per the compiler and system.


Last Updated : 26 Dec, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads