3 ms·
In that situation, Matlab allocates an array of length 3, fills it with “empty” values (depending on the type), and then sets the third element to the value. Th
by mattkrause 7y ago
In that situation, Matlab allocates an array of length 3, fills it with “empty” values (depending on the type), and then sets the third element to the value. That’s what I’d have expected to happen here too...
- zeroimpl 7y agoWould you expect it to do that if somebody wrote the following? $id = 12835151; $arr[$id] = Get_thing_with_id( $id );
- jhasse 7y agoyes.
- jrwr 7y agoIn my bog standard PHP I would do $thing = Get_thing_with_id( $id ); if(!empty($thing)){process($thing);}
- mattkrause 7y agoIf $arr were an array I would, though I'd cringe at the wasted space (unless it were a sparse array). Obviously, I'd agree that a map/associative array/dict/etc is a better choice here; I'm just annoyed about the name.