- 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.
推薦閱讀
- 手機(jī)安全和可信應(yīng)用開發(fā)指南:TrustZone與OP-TEE技術(shù)詳解
- Rust編程:入門、實(shí)戰(zhàn)與進(jìn)階
- Windows系統(tǒng)管理與服務(wù)配置
- Learning C++ Functional Programming
- Vue.js快跑:構(gòu)建觸手可及的高性能Web應(yīng)用
- Visual Basic程序設(shè)計(jì)教程
- HTML5+CSS3基礎(chǔ)開發(fā)教程(第2版)
- Linux環(huán)境編程:從應(yīng)用到內(nèi)核
- 零基礎(chǔ)學(xué)Java程序設(shè)計(jì)
- 可解釋機(jī)器學(xué)習(xí):模型、方法與實(shí)踐
- 程序設(shè)計(jì)基礎(chǔ)教程:C語言
- 圖數(shù)據(jù)庫實(shí)戰(zhàn)
- 快速入門與進(jìn)階:Creo 4·0全實(shí)例精講
- Learning Image Processing with OpenCV
- Drupal Search Engine Optimization