Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Welcome to the ReScript Forum

$
0
0

hello there!
i am trying to get input from the command line from nodejs but i can’t seem to make it work.It telling me my type is option<'a> but this function argument is expecting type string

let result = switch input {
| Some(arg) =>
  switch Belt.Int.fromString(arg) {
  | Some(year) =>
    let leapYear = isLeapYear(year)
    let message = if leapYear {
      `${year} is a leap year`
    } else {
      `${year} is not a leap year`
    }
    Js.log(message)
  | None => Js.log("Invalid year input")
  }
| None => Js.log("No year input provided")
}

Viewing all articles
Browse latest Browse all 2592

Trending Articles