- 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程序設(shè)計(jì)(慕課版)
- 編程的修煉
- Learning ArcGIS Pro 2
- 實(shí)用防銹油配方與制備200例
- x86匯編語言:從實(shí)模式到保護(hù)模式(第2版)
- SEO智慧
- Hands-On Functional Programming with TypeScript
- 零基礎(chǔ)學(xué)C語言程序設(shè)計(jì)
- Learning Grunt
- Drupal 8 Development Cookbook(Second Edition)
- Java Web開發(fā)教程:基于Struts2+Hibernate+Spring
- Mapping with ArcGIS Pro
- INSTANT LESS CSS Preprocessor How-to
- The C++ Workshop
- Tableau數(shù)據(jù)可視化從入門到精通