Hi guys, I have a simple question. I tried recently to fix a small graphic bug with my command line program I am coding. After I ask a question to the user, the program is waiting for a yes or no from it. It just need to type y | yes | n | no basically.
But how can I avoid gets to make a new line return ? I tried to enable the chomp, but change nothing
IO#gets always reads until it finds a line feed as delimiter. chomp only configures whether that trailing line feed is part of the returned string or not.
If you want to read individual characters, you can try IO#read_char.
Note that you may have to do some extra work there, though.
Infortunately no. When I press enter, the program continue to make new line.
This is my code portion:
def getUserAgreement : Bool
userInput = ""
userAgreement = false
loop do
userInput = gets
if userInput == ISM::Default::CommandLine::YesReplyOption
return true
end
if userInput == ISM::Default::CommandLine::NoReplyOption
return false
end
end
end