Hello,
How to implement an object that can do this :
myClass.add(something)(otherthings)(thisToo);
Is it possible ?
TIA,
TSalm
tsalm wrote:
Hello,
How to implement an object that can do this :
myClass.add(something)(otherthings)(thisToo);
Is it possible ?
TIA,
TSalm
Something like this might work:
class MyClass{
int[] stuff;
alias add opCall;
MyClass add(int k){
stuff ~= k;
return this;
}
}
On Wed, 10 Dec 2008 02:40:47 +0300, tsalm <[EMAIL PROTECTED]> wrote:
Hello,
How to implement an object that can do this :
myClass.add(something)(otherthings)(thisToo);
Is it possible ?
TIA,
TSalm
Yes:
import std.stdio;
class MyClass
{
class MyClassAdder
{
MyClassAdder
Reply to TSalm,
Hello,
How to implement an object that can do this :
myClass.add(something)(otherthings)(thisToo);
Is it possible ?
TIA,
TSalm
if you don't mind dropping the )(
class C
{
final void add(T...)(T t)
{
foreach(int i,_;T)
_ad
On Tue, Dec 9, 2008 at 7:00 PM, BCS <[EMAIL PROTECTED]> wrote:
> class C
> {
> final void add(T...)(T t)
> {
> foreach(int i,_;T)
> _add(t[i]);
> }
> //.
> }
>
>
> (new C).add(something, otherthings, thisToo);
If all the params are the same type, typesafe variadics are
On Wed, 10 Dec 2008 03:24:48 +0300, Jarrett Billingsley <[EMAIL PROTECTED]>
wrote:
On Tue, Dec 9, 2008 at 7:00 PM, BCS <[EMAIL PROTECTED]> wrote:
class C
{
final void add(T...)(T t)
{
foreach(int i,_;T)
_add(t[i]);
}
//.
}
(new C).add(something, otherthings, thisT
Le Wed, 10 Dec 2008 03:16:49 +0100, Denis Koroskin <[EMAIL PROTECTED]> a
écrit:
On Wed, 10 Dec 2008 03:24:48 +0300, Jarrett Billingsley
<[EMAIL PROTECTED]> wrote:
On Tue, Dec 9, 2008 at 7:00 PM, BCS <[EMAIL PROTECTED]> wrote:
class C
{
final void add(T...)(T t)
{
foreach(int i,_
Reply to Denis,
On Wed, 10 Dec 2008 03:24:48 +0300, Jarrett Billingsley
<[EMAIL PROTECTED]> wrote:
On Tue, Dec 9, 2008 at 7:00 PM, BCS <[EMAIL PROTECTED]> wrote:
final void add(T...)(T t)
If all the params are the same type, typesafe variadics are a more
efficient/less code-bloaty way to d
On Wed, 10 Dec 2008 19:31:47 +0300, BCS <[EMAIL PROTECTED]> wrote:
Reply to Denis,
On Wed, 10 Dec 2008 03:24:48 +0300, Jarrett Billingsley
<[EMAIL PROTECTED]> wrote:
On Tue, Dec 9, 2008 at 7:00 PM, BCS <[EMAIL PROTECTED]> wrote:
final void add(T...)(T t)
If all the params are the same ty