- Comprehensive Ruby Programming
- Jordan Hudgens
- 85字
- 2021-07-02 21:13:32
Stabby lambdas
In real-world projects, it's a common practice to use a different syntax though—the stabby lambda. Here is how you can use stabby lambdas:
full_name = -> (first, last) { first + " " + last }
If you run this code, it runs exactly the same way as the previous one.
Like procs, you can also run the lambdas with the call syntax:
p first_name.call("jordan", "hudgens")
So, that's how you create lambdas in Ruby with both the regular and stabby syntaxes.
推薦閱讀
- 從Java到Web程序設(shè)計(jì)教程
- HTML5 APP開發(fā)從入門到精通(微課精編版)
- C語言開發(fā)基礎(chǔ)教程(Dev-C++)(第2版)
- Creating Data Stories with Tableau Public
- Visual Basic 6.0程序設(shè)計(jì)實(shí)驗(yàn)教程
- 零基礎(chǔ)學(xué)Java第2版
- Java程序設(shè)計(jì)
- Laravel 5.x Cookbook
- Python程序設(shè)計(jì)案例教程
- Java EE框架開發(fā)技術(shù)與案例教程
- Unreal Engine 4 Game Development Essentials
- Puppet Essentials
- Mastering Puppet(Second Edition)
- Python Geospatial Analysis Cookbook
- Modular Programming with PHP 7