digitalmars.D - Type to Type[]
- Miguel Ferreira Simões (12/12) Jan 21 2005 Is there any shortcut way to create an array and insert a single element...
- Kris (3/15) Jan 21 2005 You can do something like this:
- BreMac (2/23) Jan 21 2005 That causes an Access Violation :\
- Kris (2/6) Jan 21 2005 It certainly will if 'object' is null at the time :-)
- Miguel Ferreira Simões (1/1) Jan 21 2005 Thanks!
- BreMac (5/17) Jan 21 2005 I may be mistaken, but there appears to be no way to do this. :\ I've tr...
- Chris Sauls (9/21) Jan 21 2005 The simplest solution would be array literals, which Walter has stated w...
Is there any shortcut way to create an array and insert a single element (one line only)? Instead of this: Object object; Object[] array; array ~= object; I wanna write something like this: Object object; Object[] array = cast(Object[]) object; Thanks -- Miguel Ferreira Simoes
Jan 21 2005
In article <csrm93$ofa$1 digitaldaemon.com>, Miguel Ferreira Simões says...Is there any shortcut way to create an array and insert a single element (one line only)? Instead of this: Object object; Object[] array; array ~= object; I wanna write something like this: Object object; Object[] array = cast(Object[]) object; Thanks -- Miguel Ferreira SimoesYou can do something like this:
Jan 21 2005
In article <csrndk$q21$1 digitaldaemon.com>, Kris says...In article <csrm93$ofa$1 digitaldaemon.com>, Miguel Ferreira Simões says...That causes an Access Violation :\Is there any shortcut way to create an array and insert a single element (one line only)? Instead of this: Object object; Object[] array; array ~= object; I wanna write something like this: Object object; Object[] array = cast(Object[]) object; Thanks -- Miguel Ferreira SimoesYou can do something like this:
Jan 21 2005
In article <csrnrt$qkl$1 digitaldaemon.com>, BreMac says...It certainly will if 'object' is null at the time :-)That causes an Access Violation :\
Jan 21 2005
In article <csrp44$s3q$1 digitaldaemon.com>, Kris says...In article <csrnrt$qkl$1 digitaldaemon.com>, BreMac says...Well, it is initialized... Must be just my compiler (dmd .110).It certainly will if 'object' is null at the time :-)That causes an Access Violation :\
Jan 21 2005
On Fri, 21 Jan 2005 20:36:21 +0000 (UTC), Kris <Kris_member pathlink.com> wrote:In article <csrnrt$qkl$1 digitaldaemon.com>, BreMac says...It can be null. The issue is if object goes out of scope when still using array. To be safe, use array = (&object)[0..1].dup;It certainly will if 'object' is null at the time :-)That causes an Access Violation :\
Jan 21 2005
In article <csrm93$ofa$1 digitaldaemon.com>, Miguel Ferreira Simões says...Is there any shortcut way to create an array and insert a single element (one line only)? Instead of this: Object object; Object[] array; array ~= object; I wanna write something like this: Object object; Object[] array = cast(Object[]) object; Thanks -- Miguel Ferreira SimoesI may be mistaken, but there appears to be no way to do this. :\ I've tried, and pointer manipulations of any kind seem to be forbidden by the language. (Ie. trying to set *(array[].ptr) = object causes runtime errors.) If this was allowed though... I can think of several ways to do it.
Jan 21 2005
In article <csrm93$ofa$1 digitaldaemon.com>, Miguel Ferreira Simões says...Is there any shortcut way to create an array and insert a single element (one line only)? Instead of this: Object object; Object[] array; array ~= object; I wanna write something like this: Object object; Object[] array = cast(Object[]) object; Thanks -- Miguel Ferreira SimoesThe simplest solution would be array literals, which Walter has stated will come into D in the future -- /hopefully/ before the 1.0 as I consider them an (nearly anyhow) essential tool. Once we have them, you would do something like this: -- Chris Sauls
Jan 21 2005