Avo wrote:
I'm starting in Ruby, and first I would like to translate a fonction php I made into a ruby one. In php it's very slow due to the number of possibilities, the function is :
<?php function boom($value) { $toto = "bbc4d9cb08ddbce591c28effcf6a6120005dc477";
Get PhpUnit, and write unit tests for this function. Start with the simplest cases, such as 'A'.
Then write simple unit tests in Ruby that match each input and output. "Grow" your Ruby function, by adding test cases that fail, then upgrading your function to pass. With a little perseverance, and a book on the Ruby language, you will have a rock-solid and bug-free implementation in no time.
Your design might come out the same, or different. Growing your function gives you many opportunities, while it is still small, to discover alternate patterns. The tests will make refactoring to any different pattern very easy.