The reason you get the problems is because Ruby usually accepts all names, starting with an uppercase letter, which is a constant. However, it will also allow you to define methods with a name starting with a capital letter. The following happens:
- Ruby sees
def LookAtCut and correctly defines a method called LookAtCut - Inside
LookAtCut , Ruby sees TrySlot , assumes that it is a constant, tries to find it and fails with an error, since it is not defined.
The solution is to not use method names starting with uppercase characters. Then you can use a method that is not yet defined inside another:
def a b end def b puts "Hello!" end a
source share