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.5 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.4 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.3 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.2 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.8.1 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.7.0 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.44 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.43 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.42 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.41 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.40 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.39 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.38 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.37 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.36 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.35 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.34 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.33 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.32 tracks/ocaml/exercises/hello-world/HINTS.md
trackler-2.0.6.31 tracks/ocaml/exercises/hello-world/HINTS.md