DEV Community

Cover image for Vlang now supports Lambda
h4cd
h4cd

Posted on

1

Vlang now supports Lambda

Vlang now supports Lambdas

Image description

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)
Enter fullscreen mode Exit fullscreen mode

Image description

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]) ) 
Enter fullscreen mode Exit fullscreen mode
  • will print out:
[a.v:5] f(anon_fn): /v/vnew/a
[a.v:6] f(|| os.args[0]): /v/vnew/a
Enter fullscreen mode Exit fullscreen mode

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more