Ruby is a great example of multi-paradigm programming language: it allows you to write code in object-oriented, imperative or functional styles. Ruby have much in common with functional programming languages: high-order functions, closures, anonymous functions, continuations, statements all values. If you want to use more functional programming patterns and tools, you might want to take a look on Functional Ruby gem.
- Thread-safe, immutable data structures
- Protocol specifications
- Functions overloading
- Immutable variation of Ruby’s
- Lazy execution
- Pattern matching
Install this gem with or without bundler:
And then require it in your project:
Immutable data structures
Immutable, thread-safe, write-once and read-only object variation of
Tuple is a data structure that is similar to array, but is immutable and has a fixed length.
Protocols are specifications to provide polymorphism and method-dispatch mechanism with strong typing, inspired by Clojure protocols:
If you like functional programming, and want to use it’s patterns and tools with Ruby, then you can use Functional Ruby gem to write code in more functional style. You can find more information in API documentation.