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.2 scratch/case.rb
qb-0.1.1 scratch/case.rb
qb-0.1.0 scratch/case.rb