Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
Some simple array extensions to make it easier to calculate the sum and mean values of an array's contents. A block can optionally be passed in which should return the value
to be summed/averaged.
class Array def sum(&block) inject(0) do |result, item| item = block_given? ? yield(item) : item result + (item || 0) end end def mean(&block) sum(&block).to_f / size end end
Example = Struct.new(:value) describe(Array) do it "should sum simple numbers" do Test.assert_equals([1,2,3,4].sum, 10) end examples = [Example.new(1), Example.new(3)] examples2 = [Example.new(nil), Example.new(2)] it 'should sum embedded numbers' do Test.assert_equals(examples.sum(&:value), 4) Test.assert_equals(examples2.sum(&:value), 2) end end