I am new to ReScript. I find the syntax to be quite consistent across, except these part
type person = {
age: int,
name?: string,
}
let me = {
age: 123,
name: "Hello",
}
let nameWasSet = switch me {
| {name: ?None} => false
| {name: ?Some(_)} => true
}
Why not just
let nameWasSet = switch me {
| {name: None} => false
| {name: Some(_)} => true
}
Since person.name
already has type Some<string>
.
Same goes for
add(~first=?Some(1), ~second=?Some(2))
add(~first?, ~second?)
Why not just
add(~first=Some(1), ~second=Some(2))
let first = Some(1)
let second = Some(2)
add(~first, ~second)
Since the types already explain that it is Some<number>
. Why do we need to add ?