jeudi 20 décembre 2018

F# if statement function with parameter syntax

The issue is: I cannot figure out what the error is refering to when it diplays

Here is the error: source_file.fs(10,5): error FS0010: Unexpected keyword 'if' in binding. Expected '=' or other token.

And I've been researching this error and proper syntax for a good while.

Now what I want to do, I hope, is obvious from the general look of the program.

Knowing the correct syntax would be great as microsofts docs are not great.

Seeing as this is case, I just don't understand what could be wrong.

open System

let one = "one"
let two = "two"

if oneortwo one then printfn one + " 1"
else printfn two + " 2"

let oneortwo(a : string)
    if a = "one" then return true
    elif a = "two" then return false

return false

Aucun commentaire:

Enregistrer un commentaire