stevied | ok, got another little question. I want to do something like this: `method new(%args) ` | 00:29 | |
where the signature is "autovivified" for lack of a better word, when I pass arguments to it | 00:31 | ||
so I'd have something like this: | 00:32 | ||
``` | |||
method new(%args) { | |||
%args<input_file>.IO.e ?? self.IO::Path::new(%args<input_file>)!SET-SELF() | |||
!! die "%args<input_file> is not a file"; | |||
} | |||
``` | |||
not sure if this is possible with new new constructor | 00:33 | ||
nice, worked with no problem | 00:35 | ||
what's everyone using for something similar to Lof4Perl? | 01:23 | ||
03:01
m_athias left
03:02
m_athias joined
|
|||
guifa_ | stevied: how are you passing the arguments? | 03:12 | |
%args will be defined, but empty | 03:13 | ||
(assuming no arguments passed) | |||
If you pass anything that's Associative, then %args will become that thing | |||
If you're wanting to be able to say .new(a => 4, b => 6), then you'd probably want a slurpy (that is, method new (*%args) { … } ) | 03:14 | ||
If you want to be able to handle .new('a', 4, 'b', 6), then you're best bet is to make it a multi method, with one capturing a positional slurpy, and redispatching to your single argument %args | 03:15 | ||
e.g. multi method new (*@args) { samewith Hash.new: |@args } | 03:16 | ||
04:07
sisar joined
04:12
sisar left
10:24
wingfold joined
11:01
wingfold left
11:23
razetime joined
12:12
wingfold joined
12:57
razetime left
13:06
razetime joined
13:17
lizmat_ joined,
razetime left,
TempIRCLogger__ joined
13:18
RakuIRCLogger__ left,
TempIRCLogger left
13:19
lizmat left,
lizmat_ left
13:20
lizmat joined
13:39
razetime joined
14:24
wingfold left
15:14
zacts joined
15:21
razetime left
15:29
hesh307 joined
15:30
razetime joined
16:53
zacts left
17:41
razetime left
18:34
zacts joined
19:10
zacts left
21:33
zacts joined
21:39
zacts left
22:16
zacts joined
22:18
zacts left
22:57
zacts joined
23:42
zacts left
|