17 Matching Annotations
  1. Dec 2023
  2. Sep 2023
  3. Jun 2023
    1. I’ve heard-suggested that ActiveSupport, which does a ton of monkey-patching of core classes, would make potentially-nice refinements. I don’t hold this opinion strongly, but I disagree with that idea. A big value proposition of ActiveSupport is that it is “omnipresent” and sets a new baseline for ruby behaviors - as such, being global really makes the most sense. I don’t know that anyone would be pleased to sprinkle using ActiveSupport in all their files that use it - they don’t even want to THINK about the fact that they’re using it.
  4. Nov 2022
  5. Jun 2022
  6. Jun 2021
  7. Mar 2021
    1. # Parallel Ruby universes ("Rubyverses") - A proposed interface for # parallel, "semi-private" method or method-and-data spaces via # "closely associated" objects.
    1. A proposal to specify the path for bury with classes as values of a hash arg: {}.bury(users: Array, 0 => Hash, name: Hash, something: 'Value') # {user: [{name: {something: 'Value'}]} So all absent nodes could be created via klass.new

      Didn't understand it at first, but now I think it's a pretty clever/decent solution.

      Just a bit more verbose than one might like...

      At first I had reservations about the fact that this requires you to pass a hash ... or rather, once you start using a hash as your "list", you can't just "switch back" to an array (a "problem" I've noticed in RSpec, where you have some tags that are symbols, and some that are hashes: you have to list the symbols first: describe 'thing', :happy_path, driver: :chrome):

      {}.bury(users: Array, 0, 'Value')
      

      But I think that's okay in practice. Just use a hash for all "elements" in your list:

      {}.bury(users: Array, 0 => 'Value')
      
  8. Jul 2020
    1. require 'set' class Array def uniq_elements(&prc) prc ||= ->(e) { e } uniques, dups = {}, Set.new each do |e| k = prc[e] ((uniques.key?(k)) ? (dups << k; uniques.delete(k)) : uniques[k] = e) unless dups.include?(k) end uniques.values end end