File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,23 @@ producer()
174174|> print --> 16
175175```
176176
177+ ### Methods Calls
178+ There is specialized syntax for method calls with the pipe operator, too:
179+ ``` pluto
180+ local producer = || -> 21
181+
182+ local obj = {
183+ function multiply(value)
184+ return value * self.factor
185+ end
186+ }
187+ obj.factor = 2
188+
189+ producer()
190+ |> obj:multiply
191+ |> print --> 42
192+ ```
193+
177194### Anonymous Functions
178195The righthand side of the pipe operator can also be an anonymous function, allowing for more advanced usage like this:
179196``` pluto
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ Prism.languages.pluto = {
55 / \b (? ! i n \s ) (? ! \d ) (? ! r e t u r n ) (? ! c a s e ) (? ! f u n c t i o n ) (? ! l o c a l ) (? ! n e w ) \w + (? = \s * (?: \? ? \( ) ) / , // func()
66 / \b (? ! i n \s ) (? ! \d ) (? ! r e t u r n ) (? ! c a s e ) (? ! f u n c t i o n ) (? ! l o c a l ) (? ! n o t ) \w + (? = \s * (?: \? ? [ { " ] ) ) / , // func "", func {}
77 / \b (? ! i n \s ) (? ! \d ) (? ! r e t u r n ) (? ! c a s e ) (? ! f u n c t i o n ) (? ! l o c a l ) (? ! n o t ) \w + (? = \s * (?: \? ? \[ \[ ) ) / , // func [[
8- / (?< = \| > ) \s [ \w . ] + / , // |> func
8+ / (?< = \| > ) \s [ \w . : ] + / , // |> func
99 / \b ( f u n c t i o n | e n u m | c l a s s ) \b / ,
1010 / \b ( o s \. p l a t f o r m | j s o n \. n u l l | j s o n \. w i t h n u l l | j s o n \. w i t h o r d e r ) \b / , // standard library constants
1111 / \b ( d e b u g | t a b l e | s t r i n g | n u m b e r | i o | o s | c o r o u t i n e | _ V E R S I O N | _ P V E R S I O N | _ P S O U P ) \b / , // standard library + type hints
You can’t perform that action at this time.
0 commit comments