Sha256: 2dfe752ca3024676ef6037ae65df23839b4e3e2e4310aea5f5cfbeade968f941

Contents?: true

Size: 286 Bytes

Versions: 18

Compression:

Stored size: 286 Bytes

Contents

require_relative '../function'

Dentaku::AST::Function.register(:switch, :logical, lambda { |*args|
  value = args.shift
  default = args.pop if args.size.odd?
  match = args.find_index.each_with_index { |arg, index| index.even? && arg == value }
  match ? args[match + 1] : default
})

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
dentaku-3.5.4 lib/dentaku/ast/functions/switch.rb
dentaku-3.5.3 lib/dentaku/ast/functions/switch.rb
dentaku-3.5.2 lib/dentaku/ast/functions/switch.rb
dentaku_zevo-3.5.2 lib/dentaku/ast/functions/switch.rb
dentaku-3.5.1 lib/dentaku/ast/functions/switch.rb
dentaku-3.5.0 lib/dentaku/ast/functions/switch.rb
dentaku-3.4.2 lib/dentaku/ast/functions/switch.rb
dentaku-3.4.1 lib/dentaku/ast/functions/switch.rb
dentaku-3.4.0 lib/dentaku/ast/functions/switch.rb
dentaku-3.3.4 lib/dentaku/ast/functions/switch.rb
dentaku-3.3.3 lib/dentaku/ast/functions/switch.rb
dentaku-3.3.2 lib/dentaku/ast/functions/switch.rb
dentaku-3.3.1 lib/dentaku/ast/functions/switch.rb
dentaku-3.3.0 lib/dentaku/ast/functions/switch.rb
dentaku-3.2.1 lib/dentaku/ast/functions/switch.rb
dentaku-3.2.0 lib/dentaku/ast/functions/switch.rb
dentaku-3.1.0 lib/dentaku/ast/functions/switch.rb
dentaku-3.0.0 lib/dentaku/ast/functions/switch.rb