May I call a function in a class's method?


#1

Im coding the script for simplify method in a fraction. But I thing there are code that should to be in a function… not in a method itself.
Its ok to define a function and call this function into the method in a class??


#3

Yes, for sure. It helps with mental chunking, incremental development and readability. Building functions by using other functions is called composition (it’s actually covered in Chapter 5, Topic 9 and you’ll see more examples of that in Chapter 13). You can call a functions from within any other function, even if the calling function is a method (which is essentially a function inside a class).

Check out Chapter 13, which I am guessing is just ahead for you. It’ll answer some of your fractions-related questions. :wink::sunglasses:


#4

Thank you very much!


#5

You were right Leonid. When I read chapter 13 it was there very close to my idea to solve the case. And thank you for your answer. :slight_smile: