## digitalmars.D.learn - opIndexAssign Question

• AJG (27/27) Aug 20 2005 Hi,
• Ben Hinkle (5/32) Aug 20 2005 It should be, yeah.
• AJG (14/25) Aug 20 2005 Ah, ok. Speaking of which, how come the variadic part of the function si...
AJG <AJG_member pathlink.com> writes:
```Hi,

I believe right now, if you do:

# Foo[""] = 42;
It is equivalent to:
# Foo.opIndexAssign(42, "");

If you do:

# Foo[""] = (42, 13);
It's equivalent to:
# Foo.opIndexAssign((42, 13), "");

And finally, if you do:

# Foo[""] = 42, 13;
It is equivalent to:
# (Foo[""] = 42), 13;
meaning:
# Foo.opIndexAssign(42, ""), 13;

Is that all correct?

------------

If so, is there a way to get

# Foo[""] = 42, 13;
to be equal to:
# Foo.opIndexAssign(42, 13, "");
instead?
or maybe:
# Foo.opIndexAssign([42, 13], "");
Meaning a typesafe variadic array?

Thanks,
--AJG.
```
Aug 20 2005
"Ben Hinkle" <ben.hinkle gmail.com> writes:
```"AJG" <AJG_member pathlink.com> wrote in message
news:de8a35\$1tte\$1 digitaldaemon.com...
Hi,

I believe right now, if you do:

# Foo[""] = 42;
It is equivalent to:
# Foo.opIndexAssign(42, "");

If you do:

# Foo[""] = (42, 13);
It's equivalent to:
# Foo.opIndexAssign((42, 13), "");

And finally, if you do:

# Foo[""] = 42, 13;
It is equivalent to:
# (Foo[""] = 42), 13;
meaning:
# Foo.opIndexAssign(42, ""), 13;

Is that all correct?

It should be, yeah.

------------

If so, is there a way to get

# Foo[""] = 42, 13;
to be equal to:
# Foo.opIndexAssign(42, 13, "");
instead?
or maybe:
# Foo.opIndexAssign([42, 13], "");
Meaning a typesafe variadic array?

not without changing the language. You might want to try a method instead of
using opIndexAssign. Something like Foo.insert(char[] key, int[] data...)

Thanks,
--AJG.

```
Aug 20 2005
AJG <AJG_member pathlink.com> writes:
```Hi,

If so, is there a way to get

# Foo[""] = 42, 13;
to be equal to:
# Foo.opIndexAssign(42, 13, "");
instead?
or maybe:
# Foo.opIndexAssign([42, 13], "");
Meaning a typesafe variadic array?

not without changing the language. You might want to try a method instead of
using opIndexAssign. Something like Foo.insert(char[] key, int[] data...)

Ah, ok. Speaking of which, how come the variadic part of the function signature
can't come ahead of the fixed part?

For example:

# void Foo(int[] a..., string b);

# Foo(1, 2, 3, "hello"); // OK.
# Foo("hello");          // OK.
# Foo(1, 2, 3);          // Error.
# Foo();                 // Error.
# Foo("hello", 1, 2, 3); // Error.
# Foo("hello", "world"); // Error.
# // etc...

Thanks,
--AJG.
```
Aug 20 2005