So I have a following method which works, without the use of stdin or stdout.
def main(lines)
lines.each_index do |i|
word = lines[i]
if word.length > 1 && word.length <=11
puts "I use #{word}"
end
end
end
main(["Google", "yahoo", "stackoverflow", "reddit"])
But I am trying to understand how stdin and stdout works with the above.
So when the stdin is “Google”, stdout is “I use Google”
I had to replace main(readlines)
with the above array just to make it work.
main(readlines) ===> main(["Google", "yahoo", "stackoverflow", "reddit"])
I don’t know how to implement a command line that does this.
For stdouts would it come before puts
?
stdout.puts "I use #{word}"