This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Why does this for-loop break when iterating through a multidimensional array?  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I'm trying to do is create an editable calendar made up of arrays.

First I create some variables:

Then I try to use nested for-loops to allow the user to say when they are usually asleep:

When I was building, I always had

var quantifiedMonth

set to 0, which allowed the program to work. Then I realized that if I set it to 1, then it breaks. I can't wrap my head around why, because of the output that I got when the program worked.

Say I had

then my output would be

but when

the program crashes. I can't wrap my head around why that is. To my mind, I shouldn't be able to get the output I do when

Please help. I tried to be thorough in my question, but if I'm being vague about something, please let me know.

Here's some screenshots of the errors I get

All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!