- 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.
推薦閱讀
- Web Scraping with Python
- 架構不再難(全5冊)
- ASP.NET Core 2 and Vue.js
- JS全書:JavaScript Web前端開發指南
- AutoCAD VBA參數化繪圖程序開發與實戰編碼
- HTML5入門經典
- Unity Game Development Scripting
- Babylon.js Essentials
- Hadoop大數據分析技術
- Python大規模機器學習
- 視窗軟件設計和開發自動化:可視化D++語言
- Swift High Performance
- Scratch超人漫游記:創意程序設計:STEAM創新教育指南
- 計算機視覺實戰:基于TensorFlow 2
- OpenACC并行編程實戰