Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Object array length (http://www.alice.org/community/showthread.php?t=4265)

flats 04-20-2010 10:55 AM

Object array length
 
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 [i]will[/i] 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.

Thanks!

fake edit: I know that lists are easier to use; the purpose of the exercise is to work with arrays.

x2495iiii 04-20-2010 12:06 PM

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.

flats 03-16-2011 01: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.

Bump?


All times are GMT -5. The time now is 01:56 AM.

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