I know this question is fundamental. I can take user input for a string and for an integer using:
str = gets() num = gets().to_i
But I want to read the String character (say, which is in my case more than the length of the string) by the character and count the number of characters from the first to the last for each character that appears in the string. I know that this can be achieved by:
str.length
I want to find it characteristic, because I'm trying to implement word wrapping in Ruby, which says that within the line width (which would be the number entered by the user), I would like to print only those words that do not continue until the next line, i.e. . I do not want to split a continuous word into two lines. Such words should be translated in a new line.
Thank you for your time..!!
input ruby user-input
boddhisattva
source share