var myRange = 2..10 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

var myRange = 2..10

If we: println(myRange) Why don't we get the numbers separatively?

7th Apr 2019, 8:54 AM
Alex Schmidt
Alex Schmidt - avatar
3 Answers
+ 8
Because that range is an abstraction of a range. For printing the numbers you have to iterate it. You could use this abstraction to check if a number is in the range too. Example: var myRange = 2..10 for(i in myRange) println(i) println() println(3 in myRange)
7th Apr 2019, 9:56 AM
Javier Felipe Toribio
Javier Felipe Toribio - avatar
+ 7
You are welcome
7th Apr 2019, 10:34 AM
Javier Felipe Toribio
Javier Felipe Toribio - avatar
+ 1
Thank you this helped me
7th Apr 2019, 10:08 AM
Alex Schmidt
Alex Schmidt - avatar