F# matching with two values -


I am quite new to F # and I want to compare two values ​​(with match .... .) Syntax

The problem occurs when I try to compare two values ​​like this:

  value 1 = 1 let's value 1 y = match With y Value 1 - & gt; Y + 1 | _ - & gt; Y  

I get a warning that the ". _ -> y" portion of the code will never reach. Why is it like this?

I know that for the way I want to do this, I can do the following:

  value 1 = 1 let's value 1 y = Match with. _ When y = value 1 - & gt; True | _ - & gt; False  

this also works

  value 1 = 1 is isvalue1 y = match y. 19 - & gt; True | _ - & gt; I am curious to know why I can not do this, and how this match really works. 

Value 1 is defined as a new variable within the match statement, which is worth y Is set on (in the form of a match). The value 1 that you described above is ignored, as if you were declaring a local variable with a name similar to that of a square variable in the C # function. For this reason, the position of the first match matches everything , not just the value defined before value 1, hence the error. Hope that clarifies matters.


Comments