let str = "blah"
match input with
| str -> // input = "blah" ?
| _ -> // otherwise
这样写是不对的, str在这个位置并不会被bind到变量str上,而是会和任何输入匹配,匹配的结果进入新的变量str。str在它的scope(the match clause)中遮蔽str。应该这样写:
match input with
| x when x=str -> // input = "blah"
| Modest opinions |
|
||
| by a humble autodidact | |||
![]() |
|
|
博客园
|
|