educative.io

Method name not using snake_case

Is this method name correct?


Course: https://www.educative.io/collection/10370001/5658174447157248
Lesson: https://www.educative.io/collection/page/10370001/5658174447157248/5338742977462272

Hi @Aldo_Escudero,

You’re right. This method is not written in snake_case. We can use this name in Ruby, but it is not the convention. In Ruby, the convention for method names is to use snake_case, where words are separated by underscores. For example, a method to calculate the sum of two numbers could be named count_days.

However, Ruby does allow us to use other method names (camelCase), and it is perfectly valid syntax. So, one can name the same method as count_Days if preferred.

It’s worth noting that using the convention for method names in Ruby can make your code more readable and easier to understand for other developers. Therefore, it’s generally a good idea to stick to the convention and use snake_case for method names. You can update this method name to count_days.

Thanks!

Hi @Komal_Arif,

What worries me is that in the past I have taken job interviews where the employer checks how you deal with Ruby conventions.

Thanks for your quick reply!


Course: https://www.educative.io/collection/10370001/5658174447157248
Lesson: https://www.educative.io/collection/page/10370001/5658174447157248/5638142719688704

1 Like