Hacker News new | past | comments | ask | show | jobs | submit login

No sweat, man. You are new to the language and you're putting yourself out there. Major kudos for that.

Now, for some low hanging fruits / pointers:

- $name is a global variable. Virtually unused in idiomatic Ruby.

- @name is an instance variable. So it's perfectly ok to use it... within a class.

- You should omit the 'then' after each if.

- I'd use find_words rather than busca_palabras.

- Except for rare edge cases, you can drop the .nil? from if my_var.nil?. If my_var is nil it will on its own make the condition false.

- I would use more spaces. 'a = 1' instead of 'a=1', 'b == 0' rather than 'b==0'.

- Use indentation consistently. 2 spaces.

- The else clause is indented at the same level as the leading if.

- Use && instead of 'and' in conditionals. Likewise || instead of 'or'. These short circuit the evaluation for you. So if the first argument is false && won't bother evaluating the second argument. Likewise, if the first argument is true || won't bother executing the second argument as it doesn't matter.

- Ruby is an Object-Oriented programming language. I would look into modules and classes to restructure the code in a less procedural way.




Thank you very much acangiano, I will review all the code with your guidelines at hand!.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: