Details
-
Improvement
-
Status: Closed
-
Low
-
Resolution: Won't Fix
-
None
-
None
Description
It is of value to be able to define that a parameter should be ignored. This helps in situations where a lambda needs to have several parameters, but only some of them are actually needed. The user must otherwise name the parameter. Code checking (that we do not have yet though) would then find a declared parameter that is unused.
Using a _ instead of a parameter name also serves as a clear indication that it is ignored.
There should be no problems introducing a single _ as a keyword as that is not a meaningful bare word,
Here is an example:
{a => 10, b => 20}.each |$key, _ | { notice $key } |
There are other uses cases for the single underscore, it does not always mean ignore, it can also be used as place to put a single injected values, and other use cases. The _ alone should be thought of as anonymous identifier or "Jane Doe".
Attachments
Issue Links
- relates to
-
PUP-4193 Add ability to use a lambda as case option for advanced matching
-
- Closed
-