Y-Combinators are incredibly useful functional programming tools. They allow for anonymous recursions, amongst other things. The common implementation I see in ruby is something like this:

 

  def y(&func)
    ->(x){
      ->(*args){ func[ x[x] ][*args] }
    }[ ->(x){
      ->(*args){ func[ x[x] ][*args] }
    }]
  end

 

(The above has been adapted from here)

This is then used, in the canonical factorial example, as:

 

factorial = y { |cb| ->(n) { n.zero? ? 1 : n * cb[n - 1] } }

 

This works fine, but it has that extra lambda in there, which is really just boilerplate and adds a lot of verbosity. It can be cleaned up with some currying:

 

  def ugly_y(&func)
    ->(x){
      ->(*args){ func[ x[x] ][*args] }
    }[ ->(x){
      ->(*args){ func[ x[x] ][*args] }
    }]
  end

  def y(&func)
    ugly_y { |cb| ->(*args) { func[cb, *args] } }
  end

 

Which can then be used like so:

 

factorial = y { |cb, n| n.zero? ? 1 : n * cb[n - 1] }

 

Much cleaner in my opinion.