Ruby | StringIO bytes function Last Updated : 26 Dec, 2022 Comments Improve Suggest changes Like Article Like 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. Comment More infoAdvertise with us Next Article Ruby | StringIO bytes function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads Ruby | StringScanner get_byte function StringScanner#get_byte() : get_byte() is a StringScanner class method which returns the byte of pointer on the StringScanner. Syntax: StringScanner.get_byte() Parameter: StringScanner values Return: the byte of pointer on the StringScanner. Example #1 : Ruby # Ruby code for StringScanner.get_byte() 1 min read Ruby | String bytes Method bytes is a String class method in Ruby which is used to return an array of the bytes for the given string. Syntax: str.bytes Parameters: Here, str is the specified string. Returns: An array of bytes. Example 1: Ruby # Ruby program to demonstrate # the bytes method # Taking a string and # using the m 1 min read Ruby | String bytesize method bytesize is a String class method in Ruby which is used to get the length of the given string in bytes. Syntax: str.bytesize Parameters: Here, str is the given string. Returns: This method returns the length of the str in bytes. Example 1: Ruby # Ruby program to demonstrate # the bytesize method # T 1 min read Ruby | StringScanner check function StringScanner#check() : check() is a StringScanner class method which returns the value that scan would return, without advancing the scan pointer Syntax: StringScanner.check() Parameter: StringScanner values Return: the value that scan would return, without advancing the scan pointer Example #1 : R 1 min read Ruby | String byteslice Method byteslice is a String class method in Ruby which is used for the byte reference. Syntax: str.byteslice Parameters: Here, str is the specified string. Returns: A substring of one byte at that position if only a single integer passed. A substring starting at the offset given by the first, and a length 1 min read Like