Stack Builders logo
Software developer
Justin Leitgeb Stack Builders' CTO
Jun. 20, 2014
Dec. 20, 2024
1 min read
Subscribe to blog
Check More Blogs
software development guidelines

common rails testing mistakes

Common Rails Testing Mistakes
Web Frameworks Ruby
Software developer
Justin Leitgeb
11 mins read
LinkedIn 1200 x 628 size sfadsa

refactoring javascript with functional patterns

Refactoring JavaScript with Functional Patterns
Programming Patterns JavaScript Functional Programming
Software Developer
Luis Fernando Alvarez
21 mins read
Improved syntax for currying in Ruby makes it more pleasant for functional programmers. We describe how currying has changed to make it less verbose to partially apply functions.

For aficionados of functional programming, currying is a must. According to Wikipedia, "currying is the technique of transforming a function that takes multiple arguments ... in such a way that it can be called as a chain of functions, each with a single argument." 1

Currying is considered such a fundamental part of functional programming that languages like Haskell curry by default. After doing more development in Haskell, I've lamented the verbosity of using currying in Ruby. To curry a method, you had to first grab a reference to that method, then turn that method into a proc, and finally tell it to work with partial application:

> def add a, b ; a + b; end
=> :add
> method(:add).to_proc.curry
=> #<Proc:0x007fa9e2140af8 (lambda)>

This just changed yesterday in Ruby head, and you can now call curry directly on an instance of the Method class!

> def add a, b ; a + b; end
=> :add
> method(:add).curry
=> #<Proc:0x007fa9e2140af8 (lambda)>

Although this is a relatively minor change, it's a step in the right direction for functional programming in Ruby. Kudos to Arne Brasseur for making this change!

Check More Blogs
software development guidelines

common rails testing mistakes

Common Rails Testing Mistakes
Web Frameworks Ruby
Software developer
Justin Leitgeb
11 mins read
LinkedIn 1200 x 628 size sfadsa

refactoring javascript with functional patterns

Refactoring JavaScript with Functional Patterns
Programming Patterns JavaScript Functional Programming
Software Developer
Luis Fernando Alvarez
21 mins read
Subscribe to blog