Sha256: 7b13ad48339f1510a2660c91462a4a28ea4d3f129107f6fc5810b74fda6a1001
Contents?: true
Size: 506 Bytes
Versions: 24
Compression:
Stored size: 506 Bytes
Contents
class Array class SizeMismatch < StandardError; end DOT_OPERATIONS = { :dotplus => :+, :dotminus => :-, :dotmul => :*, :dotdiv => :/, :dotmod => :%, :dotpow => :**, :dotaddsemi => :addsemi, } DOT_OPERATIONS.each { |op, m| define_method(op) { |other| dotop(m, other) } } protected def dotop(op, other) raise SizeMismatch unless self.size == other.size res = [] self.each_index { |idx| res << (self[idx].send(op, other[idx])) } res end end
Version data entries
24 entries across 24 versions & 1 rubygems