Pattern matching on the beginning of a string in f#

后端 未结 3 1351
遥遥无期
遥遥无期 2020-12-23 19:21

I am trying to match the beginning of strings in f#. Not sure if I have to treat them as a list of characters or what. Any suggestions would be appreciated.

Here i

3条回答
  •  悲哀的现实
    2020-12-23 19:32

    You could also use a guard on the pattern:

    match text with
    | txt when txt.StartsWith("The") -> true
    | txt when txt.StartsWith("If") -> true
    | _ -> false
    

提交回复
热议问题