Sha256: 215a2fec9b62668239d706a8cc5ae37daed1c2a77c95c7ccf9e39ca9b83ac14c

Contents?: true

Size: 901 Bytes

Versions: 126

Compression:

Stored size: 901 Bytes

Contents

## Use of `option`
The type signature of the `greet` function reads `string option -> string`. It
could be that this is your first time to encounter an Option type.

An option type is an explicit way to signal that a value could be missing for a
legitimate reason.

In OCaml Options types are implemented as
a [variant type](https://realworldocaml.org/v1/en/html/variants.html) something
like

```ocaml
type 'a option =
    | None
    | Some of 'a
```

In the case of `string option` you provide an argument using one of the
following snippets

1. `None` to signal that no subject is passed.
2. `Some("Alice")` to provide an actual subject.

Just like other variants types you can match on an option. The example below
demonstrates how this can be done. Here `x` is an `string option`.

```ocaml
match x with 
    | None           -> "no argument passed"
    | Some(argument) -> "argument passed"
```

Version data entries

126 entries across 126 versions & 1 rubygems

Version Path
trackler-2.0.5.9 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.5.8 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.5.7 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.5.6 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.5.5 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.5.4 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.5.3 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.5.2 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.5.1 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.5.0 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.4.0 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.3.9 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.3.8 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.3.7 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.3.6 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.3.5 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.3.4 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.3.3 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.3.2 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.3.1 tracks/ocaml/exercises/hello-world/HINTS.md