Ad
  • Custom User Avatar

    A more elegant request would be to allow unlimited chaining of calculations. The result could be obtained by implementing to_s and to_f. E.g. puts Calc.new.one.plus.two.times.three # 9.0

  • Custom User Avatar

    Ruby, test suite lacks :

    -testing for implementing zero

    -random tests

  • Custom User Avatar

    The final tests dont catch it if you forget to implement zero.

  • Custom User Avatar

    This one was a lot of fun! I enjoyed seeing all the different approaches in the solutions.

  • Custom User Avatar

    Mine's pretty straightforward as well. Reduce takes operators as symbols, which is incredibly useful in this case.

  • Custom User Avatar

    I found it unclear that this only had to be built to handle exactly 3 chained methods, not an arbitrary amount. So for anyone wondering, you only need it to work for Calc.new.number.operator.number. Nothing else.

  • Custom User Avatar

    It looks like you're returning a method instead of a number. Maybe ensure you're returning a number?

  • Custom User Avatar

    The most interesting solution. Mine is also not using eval, but quite simple and easy to read. @JoshBrodieNZ your solution is universal, man, you could use it for half of katas with minor changes ;)

  • Custom User Avatar

    My code work fine in my local machine but when tryingto submit the test always return the same

    Expected: 9, instead got: #
     `expect': Expected: 9, instead got: # (Test::Error)
    	from `assert_equals'
    	from  `
    '
    

    I don't know if the is something wrong with the test. Could someone take a look.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I also hate eval and haven't ever used curry, but I will now!

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    think about the different ways each method should respond based on the state of the class. Since we know the calc should execute once given three inputs...you can setup your methods to behave differently

  • Custom User Avatar

    I have never seen curry, setobj, and calling super with a lamba is pretty crazy too...

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Loading more items...