42 Matching Annotations
  1. Jul 2021
  2. Jun 2021
    1. Or if you're looking for a core extension that adds this to the Array class, I'd recommend the facets gem (require 'facets/array/average'). Then you can just do array.average. And, from looking at the source, it turns out they do the exact same thing as the instance_eval approach above. The only difference is that it's implemented as a method—which of course already has self pointing to itself—instead of a block): def average; return nil if empty?; reduce(:+) / length.to_f; end Main advantage of this is that it's even more concise/readable and it handles the empty? case.
  3. Apr 2021
  4. Mar 2021
  5. Feb 2021
  6. Jun 2020
  7. May 2020
  8. Apr 2020
    1. minitest doesn't reinvent anything that ruby already provides, like: classes, modules, inheritance, methods. This means you only have to learn ruby to use minitest and all of your regular OO practices like extract-method refactorings still apply.
  9. Mar 2020
  10. Feb 2020
  11. Dec 2019