Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Input-loop/Fantom/input-loop.fantom
Normal file
26
Task/Input-loop/Fantom/input-loop.fantom
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
class Main
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
// example of reading by line
|
||||
str := "first\nsecond\nthird\nword"
|
||||
inputStream := str.in
|
||||
|
||||
inputStream.eachLine |Str line|
|
||||
{
|
||||
echo ("Line is: $line")
|
||||
}
|
||||
|
||||
// example of reading by word
|
||||
str = "first second third word"
|
||||
inputStream = str.in
|
||||
|
||||
word := inputStream.readStrToken // reads up to but excluding next space
|
||||
while (word != null)
|
||||
{
|
||||
echo ("Word: $word")
|
||||
inputStream.readChar // skip over the preceding space!
|
||||
word = inputStream.readStrToken
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue