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.8.26 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.24 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.23 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.22 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.21 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.20 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.19 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.18 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.17 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.16 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.15 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.14 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.13 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.12 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.11 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.10 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.9 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.8 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.7 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.6 tracks/ocaml/exercises/hello-world/HINTS.md