On 2020-08-30 00:35, Tobias Boege wrote:
On Sun, 30 Aug 2020, ToddAndMargo via perl6-users wrote:
- You are calling .lines on the value of .IO.open which is an
IO::Handle. IO::Handle.lines does not take a named argument
:chomp, so passing one is useless.
That explains it.
Butttttttt:
https://docs.raku.org/type/IO::Path#method_lines
(IO::Path) method lines
Defined as:
method lines(IO::Path:D: :$chomp = True, :$enc = 'utf8', :$nl-in =
["\x0A", "\r\n"], |c --> Seq:D)
Opens the invocant and returns its lines.
The behavior is equivalent to opening the file specified
by the invocant, forwarding the :$chomp, :$enc, and
:$nl-in arguments to IO::Handle.open, then calling
IO::Handle.lines on that handle, forwarding any of
the remaining arguments to that method, and returning
the resultant Seq.
The "signature" line (cryptogram) clearly stated that
":$chomp" is a parameter of the method.
Now you are obviously correct that :chomp is ignored.
If I am not mistaken, I have just tripped over another
error in the documentation. Your take?
You confuse two methods that have the same name "lines". One of them,
which exists in the IO::Path class, has a :chomp argument. The other,
on IO::Handle does not.
"path".IO.lines() <-- calls lines on an IO::Path (supports :chomp)
"path".IO.open.lines() <-- calls lines on an IO::Handle (does not support
:chomp)
In the second case, if you want chomping to happen you have to pass
the :chomp to the *open* call, as you do below:
Hi Tobias,
The terrible example they included was:
'50GB-file'.IO.lines.grep(*.contains: 'Perl').elems,
" lines that mention Perl";
I left off the "grep" and the "elems".
"Lines.txt".IO.open.lines
This was the example they gave for
method lines(IO::Path:D: :$chomp = True, :$enc = 'utf8', :$nl-in =
["\x0A", "\r\n"], |c --> Seq:D)
Exactly what is "IO::Path:D:"?
I know that :D is declared and the ":" after it
is a delimiter. That leaved "IO::Path":
https://docs.raku.org/type/IO::Path
And I can't make heads or tails out of the page.
My goal is to learn how to use :$chomp = True,
:$enc = 'utf8', :$nl-in, and, |c
Thank you for the help!
-T