Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a reason why It.Is only accepts an expression, thus breaking type inference? #150

Closed
WillSullivan opened this issue Jan 29, 2015 · 3 comments

Comments

@WillSullivan
Copy link

I seem to remember you could just pass in a regular old value and it would be satisfied

It.Is(1) 

rather than

It.Is<int>(x => 1 == x ) // ERRY GOTDAMN TIME

Seems like it's trivial to implement, like this replacement

public static class Is
{
    public static TValue Exactly<TValue>(TValue value)
    {
        return Match<TValue>.Create<TValue>(v => EqualityComparer<TValue>.Default.Equals(value, v));
    }
}

So why not? Is there some corner case or issue when processing this Match down the road? I can understand that there are assumptions about what is considered equality, but if we know what the deal is going in, why do we have to bash ourselves over the head with the Expression route?

@stakx
Copy link
Contributor

stakx commented Jun 21, 2017

@WillSullivan: Why would you choose to write It.Is(1) if you can just as well write 1?

@WillSullivan
Copy link
Author

@stakx Forgot about this stinker right here. Of course that's the exact way it's done. At the time I wrote this I was trying to remember how I had previously been able to pass in a constant value. Was just looking in the wrong place. I'll clean up my mess, thanks.

@stakx
Copy link
Contributor

stakx commented Jun 21, 2017

Thanks for the response... no worries! ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants