Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Thread Tools Display Modes
Object array length
Posts: n/a
Default Object array length - 04-20-2010, 09:55 AM

Is there a convenient way to get the length of an Object array? When I drag it over a number field, it just disappears.

I've found the following will work, but there's got to be an easier way:

1) Create another array (number/boolean/etc)
2) Drag that over a number field, choose size
3) Drag your object array over the array from #2
4) Delete the array from #1

Some of my students are working on writing methods that take Object arrays as a parameter and iterate through them, and I was hoping there'd be an easier way to have them find the array length than this.


fake edit: I know that lists are easier to use; the purpose of the exercise is to work with arrays.
Reply With Quote
Super Moderator
x2495iiii's Avatar
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 04-20-2010, 11:06 AM

It doesn't look like there's an easier way. From what I can tell, arrays in Alice are the same as list, but less concrete (I told one of the lists to set it's 2nd value to cheshire cat when it only had one item in it, and instead of generating an error it generated an empty slot for item 1, then the cheshire cat for item 2).

Sorry about that.

Reply With Quote
Posts: n/a
Default 03-16-2011, 12:57 PM

I just Googled this question and ended up here. I forgot I had it in the first place last year.

Guess who's in the same place of his curriculum.

Reply With Quote

array, length

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright ©2021, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.