Sha256: c85f6fbd2874f72dfc675cd425bc8ed3f4ce8b0e5f68c3bcce2bbab0c83ffbb6

Contents?: true

Size: 499 Bytes

Versions: 43

Compression:

Stored size: 499 Bytes

Contents

class Object
  def on_length procs
    length_map = procs.map {|proc|
      [proc.arity, proc]
    }.to_h
    
    length_map[length].(*self)
  end
end

def f args
  puts "args: #{ args.inspect }"
  args.on_length([
    -> {
      puts "none"
    },
    ->(x) {
      puts "single: #{ x }"
    },
    ->(x, y) {
      puts "double: #{ x }, #{ y }"
    },
  ])
  puts
end

f = (args) ->
  (x) ->
    (x:Hash) ->
      ['', x]
    (x) ->
      [x, {}]
      
  (x, y) -> [x, y]

f []
f [:x]
f [:x, :y]

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
qb-0.1.42 dev/scratch/case.rb
qb-0.1.41 dev/scratch/case.rb
qb-0.1.40 dev/scratch/case.rb
qb-0.1.39 dev/scratch/case.rb
qb-0.1.38 dev/scratch/case.rb
qb-0.1.37 dev/scratch/case.rb
qb-0.1.36 dev/scratch/case.rb
qb-0.1.35 dev/scratch/case.rb
qb-0.1.34 dev/scratch/case.rb
qb-0.1.33 dev/scratch/case.rb
qb-0.1.32 dev/scratch/case.rb
qb-0.1.31 dev/scratch/case.rb
qb-0.1.30 dev/scratch/case.rb
qb-0.1.29 dev/scratch/case.rb
qb-0.1.28 dev/scratch/case.rb
qb-0.1.27 dev/scratch/case.rb
qb-0.1.26 dev/scratch/case.rb
qb-0.1.25 dev/scratch/case.rb
qb-0.1.24 dev/scratch/case.rb
qb-0.1.23 dev/scratch/case.rb