You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MoonBit provides a convenient pipe operator |>, which can be used to chain regular function calls:
fn init {
x |> f // equivalent to f(x)
x |> f(y) // equivalent to f(x, y)
// Chain calls at multiple lines
arg_val
|> f1 // equivalent to f1(arg_val)
|> f2(other_args) // equivalent to f2(f1(arg_val), other_args)
}
This is from Moonbit doc, it is cool. But the syntax is not intuitive for multi-parameter functions, because the second argument is written in the first position, this is inconsistent with directly function call. (method call has an implicit receiver parameter which is consistent with function signature, but the pipe syntactic sugar is completely different)
So I suggest we use _ placeholder syntax maybe like this x |> f(_, y) or x |> f($, y)
This also makes we can pipe to second or third parameter not only first:
MoonBit provides a convenient pipe operator |>, which can be used to chain regular function calls:
This is from Moonbit doc, it is cool. But the syntax is not intuitive for multi-parameter functions, because the second argument is written in the first position, this is inconsistent with directly function call. (method call has an implicit receiver parameter which is consistent with function signature, but the pipe syntactic sugar is completely different)
So I suggest we use
_
placeholder syntax maybe like thisx |> f(_, y)
orx |> f($, y)
This also makes we can pipe to second or third parameter not only first:
Originally posted by @bnyu in #299 (comment)
The text was updated successfully, but these errors were encountered: