Jump to content

Input loop: Difference between revisions

m
→‎{{header|Sidef}}: modified the code to work with Sidef 2.30
m (→‎{{header|Sidef}}: modified the code to work with Sidef 2.30)
Line 1,851:
=={{header|Sidef}}==
To read from the standard input, you can use '''STDIN''' as your '''fh'''.
<lang ruby>var file = File.new(__FILE__);
file.open_r(\var fh, \var err) || die "#{file}: #{err}"
|| "Can't open file `#{file}': #{err}\n".die;
 
fh.each { |line| # iterates the lines of the fh
line.each_word { |word| # iterates the words of the line
say word;
}
}</lang>
2,747

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.