Extending 'Normal Extensions' with 'PolyArg Extensions' & New 'club' Keyword #7616
Replies: 3 comments 4 replies
-
var result = ("Sangeeth", 24).IsAGoodBoyUnder24();
if (result)
{
Console.WriteLine("Hey young good boy");
}
public static class PolyArgExtensions
{
public static bool IsAGoodBoyUnder24(this (string name, int val) t)
{
return t.name == "Sangeeth" && t.val < 24;
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
-
What’s the benefit? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Ya it makes sense, I'm closing the discussion. Thanks folks |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In C# we've normal extension methods that can accept one parameter along the "this" keyword
Existing Extension Support
Then use like
Proposed Improved Extension Support
The "PolyArg" Concept
The proposed "PolyArg" extension methods would allow extension method signatures to accept multiple arguments using the this keyword. For example:
Prerequisites
club
(Similar to "typeof," "nameof," and "stackalloc")Discussion Points
This proposal raises several questions and considerations:
"club"
keyword is a good idea, and can it unlock potential future language features?Example - Using "Extension with Tuple" vs. Using "Native PolyArg Extensions" Support
To illustrate the benefits of "PolyArg" extensions, consider this comparison between the tuple approach and the proposed "club" keyword approach:
Beta Was this translation helpful? Give feedback.
All reactions