On 04/01/2012 10:45 PM, Chris Pons wrote:
I'm trying to add an element to a list with insert but that doesn't seem
to do anything at all. If I try using ~= it says that Error: cannot
append type Node to type SList!(Node). I'm pretty confused about using
~= because it works fine for arrays but
On 2 April 2012 17:45, Chris Pons cmp...@gmail.com wrote:
I'm trying to add an element to a list with insert but that doesn't seem to
do anything at all. If I try using ~= it says that Error: cannot append
type Node to type SList!(Node). I'm pretty confused about using ~= because
it works fine
Thanks. I tried doing this and the list didn't update:
void AddToList( SList!int list, int i )
{
list.insert( i );
}
SList!int intList;
AddToList( intList, 42 );
but when I switched to this, it worked:
SList!int intList;
void AddToList( int i )
{
intList.insert( i );
}
AddToList(
On 04/01/2012 11:18 PM, Chris Pons wrote:
Thanks. I tried doing this and the list didn't update:
void AddToList( SList!int list, int i )
{
list.insert( i );
}
Oh, that has nothing to do with SList. SList is a struct and as a
fundamental rule of D, structs are copied to functions. SList
Ah, thank you. I didn't realize taht SList is a struct and that
it used value semantics. That clears this up.
On Monday, 2 April 2012 at 14:22:25 UTC, Ali Çehreli wrote:
On 04/01/2012 11:18 PM, Chris Pons wrote:
Thanks. I tried doing this and the list didn't update:
void AddToList(
On Monday, April 02, 2012 20:27:18 Chris Pons wrote:
Ah, thank you. I didn't realize taht SList is a struct and that
it used value semantics. That clears this up.
It really shouldn't be using value semantics (though it wouldn't surprise me
if it is - I haven't used it). std.container's
I'm trying to add an element to a list with insert but that
doesn't seem to do anything at all. If I try using ~= it says
that Error: cannot append type Node to type SList!(Node). I'm
pretty confused about using ~= because it works fine for arrays
but apperantly not for lists.
How do I add