Vlang now supports Lambdas
Vlang (aka V) is a static language that combined the simplicity of Golang and safety of Rust. It is very close to Golang, so if you know Go, you just have a 80% experience about V. Here is some point where V enhanced from Go: https://vlang.io/compare#go
According to PR merge information of the repo, V has now supported lambda expression, be like:
a.sorted(|x,y| x > y)
https://github.com/vlang/v/pull/19390
demo:
- call back with fn or expression, get their value from outer source:
import os
fn f( cb fn() string ) string { return cb() }
dump( f(fn() string { return os.args[0] }) )
// the same, just shorter:
dump( f(||os.args[0]) )
- will print out:
[a.v:5] f(anon_fn): /v/vnew/a
[a.v:6] f(|| os.args[0]): /v/vnew/a
Top comments (0)