Ruby | String each_str Method Last Updated : 12 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report each_str is a String class method in Ruby which is used to passes each character in the given string to the given block, or returns an enumerator if no block is given. Syntax: str.each_byte Parameters: Here, str is the given string. Returns: An enumerator. Example 1: Ruby # Ruby program to demonstrate # the each_char method # Taking a string and # using the method puts "Ruby".each_char{|b| print b, ' ' } puts "Programming".each_char{|b| print b, ' ' } Output: R u b y Ruby P r o g r a m m i n g Programming Example 2: Ruby # Ruby program to demonstrate # the each_char method # Taking a string and # using the method puts "Sample".each_char{|b| print b, ' ' } puts "Input".each_char Output: S a m p l e Sample # Comment More infoAdvertise with us Next Article Ruby | String each_str Method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads Ruby | String chr Method chr is a String class method in Ruby which is used to return a one-character string at the beginning of the string. Syntax:str.chr Parameters: Here, str is the given string. Returns: A one-character string at the beginning of the string. Example 1: Ruby # Ruby program to demonstrate # the chr method 1 min read Ruby | String each_line Method each_line is a String class method in Ruby which is used to split the given string sing the supplied parameter as the record separator ($/ by default), passing each substring in turn to the supplied block. The string is split into paragraphs delimited by multiple successive newlines if a zero-length 1 min read Ruby | String each_byte Method each_byte is a String class method in Ruby which is used to passes each byte in the given string to the given block or returns an enumerator if no block is given. Syntax: str.each_byte {|integer| block } Parameters: Here, str is the given string. Returns: An enumerator. Example 1: Ruby # Ruby progra 1 min read Ruby | String hash method hash is a String class method in Ruby which is used to return a hash based on the string's length, content and encoding. Syntax: str.hash Parameters: Here, str is the given string. Returns: A hash based on the string's length, content and encoding. Example 1: Ruby # Ruby program to demonstrate # the 1 min read Ruby | String chop Method chop is a String class method in Ruby which is used to return a new String with the last character removed. Both characters are removed if the string ends with \r\n, b. Applying chop to an empty string returns an empty string. Syntax:str.chopParameters: Here, str is the given string.Returns: A new 1 min read Like