Skip to content
Related Articles

Related Articles

Ruby | StringIO bytes function

View Discussion
Improve Article
Save Article
  • Last Updated : 12 Dec, 2019
View Discussion
Improve Article
Save Article

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 code for StringIO.bytes() method
  
# loading StringIO
require 'stringio'
  
# declaring StringIO 
a = StringIO.new("geeksforggeks")
  
  
# StringIO 
puts "StringIO a : #{a.string}\n\n"
  
  
# bytes form 
puts "StringIO a bytes form : #{a.bytes}\n\n"

Output :

StringIO a : geeksforggeks

StringIO a bytes form : #

Example #2 :




# 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 Enumertaor value can change as per the compiler and system.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!