Example provided in coconut documentation
obj |> .attribute |> .method(args) |> func$(args) |> .[index]
However i would like to know how can we apply two methods one after the other that do not return anything, they just modify the object
For example:
(
data
|> Model
|> .fit() # does not return anything
|> .summary() # therefore, this throws an error
)
m = Model()
m.fit()
m.summary()
If you really want to use pipes for this, you can use a statement lambda to do
m = (
data
|> Model
|> (def m -> m.fit(); m)
|> .summary()
)
though the Python code will also work in Coconut just fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.