Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Ruby | String bytes Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 program to demonstrate
# the bytes method
     
# Taking a string and
# using the method
puts "String".bytes

Output:

83
116
114
105
110
103

Example 2:




     
# Ruby program to demonstrate
# the bytes method
     
# Taking a string and
# using the method
puts "ABCD".bytes

Output:

65
66
67
68
My Personal Notes arrow_drop_up
Last Updated : 07 Jan, 2020
Like Article
Save Article
Similar Reads