Optional record fields

If you have an option value from optional labeled arguments, prefix it with ? to set an optional record field directly.

type person = {
  age: int,
  name?: string
}
 
let maybeName = Some("My Name")
 
let me = {
  age: 123,
  name: ?maybeName
}

This trick also works in JSX.

let name = Some("Andrea")
 
<Greeting ?name />

Passing optional argument to another function

let result = drawCircle(~color, ~radius=?payloadRadius)