Why use preformatted coding? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 12

Why use preformatted coding?

This may be my key for understanding all languages. My question is why do you use things such as this in Ruby: var = [2, 4, 5] arr << 7 puts arr[2] and why not: puts 5. I'm wondering about ot, because sometimes it can make the mix very complicated. Some you use it is easier but else not. Please share your thoughts and let me know! #yourawesome

1st Jun 2017, 6:35 PM
Iwan
Iwan - avatar
1 Answer
+ 5
The use of arrays is most of the time for manipulation of data for multiple choise or data collected out of a database. In your example, the 5 could be something completely different after a few runs, but then it has to be manipulated by some parameters.
2nd Jun 2017, 12:14 PM
🇺🇸 Anatoli🇧🇪🇪🇺 ,
🇺🇸 Anatoli🇧🇪🇪🇺 , - avatar