From: "Jan E." Date: 2012-09-28T18:08:52+09:00 Subject: Re: calcaulation with unknown numbers of numbers and options fail Hi, Roelof Wobben wrote in post #1077862: > I can declare it as this def calculate (*arguments) > So i will be one hash but then I have to figure out how to seperate the > options part and the numbers parts. Then why do you do it? Just set the parameter list according to the method call: def calculate *numbers, options ... end I'm also quite sure that you're not supposed to subtract the numbers from 0 but rather from each other. So calculate(1, 2, {}) should yield 1 - 2 = -1 and not 0 - 1 - 2 = -3. In this case you must omit the "0" parameter for "inject". And you should use the short form: def calculate *numbers, options operator = options[:add] ? :+ : :- numbers.reduce operator end puts calculate 3, 5, add: true puts calculate 3, 5, add: false puts calculate(3, 5, {}) -- Posted via http://www.ruby-forum.com/.