This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
fennewald hey, what's the way to do Optional return types. Specifically, if I define a function that will either return a `Str` or nothing at all, what is the best way to do that? 00:27
jaguart Just set the return type to Str - the 'or Nil' is implicit 02:58
docs.raku.org/language/functions#R...onstraints 03:00
Says: `Note that Nil and Failure are exempt from return type constraints and can be returned from any routine, regardless of its constraint`
I'm not that experienced, but I wonder if the Signature constraint e.g. sub foo(--> Int) {} somewhat differs from the trait-like syntax: sub foo() returns Int {}; 03:04
in that under introspection, the Signature of the first sub is different from the signature of the second.
and maybe that makes a difference for multis? 03:05
oh - just found this too: docs.raku.org/type/Signature#returns which says 'the pointy arrow form is always preferred' 03:15
Nemokosch fennewald: more to this. the `Str` type signature covers "definite" and "indefinite" values of `Str` 10:17
"definite" values are concrete instances with appropriate data while the only indefinite instance is the type object `Str` itself. You can denote that you want definite content with `Str:D` and you can mark your data as "indefinite" using `Str:U` 10:18
in some sense, `Str` can stand for "nothing at all, *as a string*". Same for all type objects. This means that you can retain strict types with missing values as well, if that's what you want 10:21
by the way: since anything ultimately descends from `Mu`, you can catch all type objects by `Mu:U` 10:24