Anishluke92 / RubySolution

Problem solving using Ruby programming language
0 stars 1 forks source link

Recursion: Length of a String #14

Closed danielpaul closed 2 years ago

danielpaul commented 4 years ago

Write a function that returns the length of a string. Make your function recursive.

Examples

length("apple") ➞ 5

length("make") ➞ 4

length("a") ➞ 1

length("") ➞ 0

Notes Check the Resources tab for info on recursion.

Anishluke92 commented 4 years ago

What do you mean by make a function recursive ?

danielpaul commented 4 years ago

What do you mean by make a function recursive ?

have a look at the differences between iterative methods and recursive methods. https://medium.com/backticks-tildes/iteration-vs-recursion-c2017a483890

So the recursive method is something that calls itself. So this is a bit of new thing that you possibly have not done yet that we need to learn. Some links that might help to understand the concept of recurssion:

Anishluke92 commented 4 years ago

I will look into it !