https://github.com/alesya-h/fn-syntax
Lambda shorthand: fn{ _1 * 2 } instead of lambda{|x| x*2}
https://github.com/alesya-h/fn-syntax
ruby syntax-sugar
Last synced: 4 months ago
JSON representation
Lambda shorthand: fn{ _1 * 2 } instead of lambda{|x| x*2}
- Host: GitHub
- URL: https://github.com/alesya-h/fn-syntax
- Owner: alesya-h
- License: mit
- Created: 2014-06-10T16:44:57.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-10T17:03:34.000Z (about 12 years ago)
- Last Synced: 2026-01-14T10:44:19.289Z (5 months ago)
- Topics: ruby, syntax-sugar
- Language: Ruby
- Size: 137 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# FnSyntax
Adds fn method to define anonymous functions with args available as _1, _2, _3 upto _9
## Installation
Add this line to your application's Gemfile:
gem 'fn_syntax'
And then execute:
$ bundle
Or install it yourself as:
$ gem install fn_syntax
## Usage
require 'fn_syntax'
times_four = fn{ _1 * 4 }
(1..5).map ×_four # => [4, 8, 12, 16, 20]
## Contributing
1. Fork it ( https://github.com/alesguzik/fn_syntax/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request