From 26f7464d6e44dae518ebd5ae848d110e38296c55 Mon Sep 17 00:00:00 2001 From: ming <1570977353@qq.com> Date: Mon, 20 Mar 2023 21:57:52 +0800 Subject: [PATCH] add usage `fst` and `snd` for tuple --- pages/docs/manual/latest/tuple.mdx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pages/docs/manual/latest/tuple.mdx b/pages/docs/manual/latest/tuple.mdx index 2790ee67b..4df959015 100644 --- a/pages/docs/manual/latest/tuple.mdx +++ b/pages/docs/manual/latest/tuple.mdx @@ -59,6 +59,24 @@ var y = 30.5; +To get first or second member of a tuple, use `fst` or `snd` function: + +fst +let s = tup->snd +``` +```js +var tup = [ + 1, + "ReScript" +]; +var f = 1; +var s = "ReScript"; +``` + + The `_` means you're ignoring the indicated members of the tuple. Tuples aren't meant to be updated mutatively. You'd create new ones by destructuring the old ones: