Ruby trick on arrays

We can convert the array to the sentences using the ‘to_sentence’ method in the Ruby.

Example :-

array=[“First Task”, “Second Task”, “Third Task”]

result=array.to_sentence

Result :-

“First Task, Second Task, and Third Task”

Advertisements