bytesize
is a method in Ruby that is used to count the number of bytes in a string.
It gets the length of a string in bytes.
str.bytesize
bytesize
does not take any parameters.
The value returned is an integer value that represents the count of bytes in a string.
In the code below, we will create some strings and get their sizes in bytes.
# create stringsstr1 = "Edpresso"str2 = "is"str3 = "the best"# get the bytes sizesa = str1.bytesizeb = str2.bytesizec = str3.bytesize# print out returned valuesputs aputs bputs c