doc: update readme
This commit is contained in:
parent
958fe9e674
commit
6ec872969f
2 changed files with 33 additions and 2 deletions
32
README.md
32
README.md
|
@ -285,6 +285,38 @@ Add `nix2lua` as input to your `flake.nix`
|
|||
> # local function foo(bar) bar.baz() end
|
||||
> ```
|
||||
|
||||
`return expr`
|
||||
|
||||
> Return expression from a function.
|
||||
>
|
||||
> ```nix
|
||||
> toLua (func "foo" ["bar"] (return (pipe1 "bar" "baz"));
|
||||
> # function foo(bar) return bar.baz end
|
||||
> ```
|
||||
>
|
||||
> Useful aliases:
|
||||
> ```
|
||||
> return_void = return null;
|
||||
> ```
|
||||
|
||||
`ifelse condition trueBody falseBody`
|
||||
|
||||
> Make a Lua if else statement.
|
||||
>
|
||||
> ```nix
|
||||
> toLua (ifelse (eq 10 10) (call "print" "yes") (call "print" "no"));
|
||||
> # if (10 == 10) print("yes") else print("no") end
|
||||
> ```
|
||||
|
||||
`if' condition trueBody`
|
||||
|
||||
> Make a Lua if statement without else.
|
||||
>
|
||||
> ```nix
|
||||
> toLua (if' (eq 10 10) (call "print" "yes"));
|
||||
> # if (10 == 10) print("yes") end
|
||||
> ```
|
||||
|
||||
# License
|
||||
|
||||
GNU General Public License v3.0 or later
|
||||
|
|
3
lib.nix
3
lib.nix
|
@ -152,8 +152,7 @@ let
|
|||
lambda0 = lambda [ ];
|
||||
|
||||
return = expr: spaceBetween ([ kw_return expr ]);
|
||||
return_void = return
|
||||
null;
|
||||
return_void = return null;
|
||||
|
||||
ifelse = condition: trueBody: falseBody:
|
||||
(spaceBetween (concatLists [
|
||||
|
|
Loading…
Reference in a new issue