On Wed, Apr 26, 2023 at 06:24:08PM +, DLearner via Digitalmars-d-learn
wrote:
> Consider:
> ```
> struct S1 {
>int A;
>int B;
>int foo() {
> return(A+B);
>}
> }
>
> struct S2 {
>int A;
>int B;
> }
> int fnAddS2(S2 X) {
>return (X.A + X.B);
> }
>
> void
On Wednesday, 26 April 2023 at 18:24:08 UTC, DLearner wrote:
Consider:
```
struct S1 {
int A;
int B;
int foo() {
return(A+B);
}
}
struct S2 {
int A;
int B;
}
int fnAddS2(S2 X) {
return (X.A + X.B);
}
There are scenarios that won't let you use the second form, e.g.
On 27/04/2023 11:07 AM, WhatMeWorry wrote:
On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki) Andrew
Cattermole wrote:
Don't forget ``num % 2 == 0``.
None should matter, pretty much all production compilers within the
last 30 years should recognize all forms of this and do the right
Consider:
```
struct S1 {
int A;
int B;
int foo() {
return(A+B);
}
}
struct S2 {
int A;
int B;
}
int fnAddS2(S2 X) {
return (X.A + X.B);
}
void main() {
import std.stdio : writeln;
S1 Var1 = S1(1, 2);
writeln("Total Var1 = ", Var1.foo());
S2 Var2 = S2(1,
On Wednesday, 26 April 2023 at 18:24:08 UTC, DLearner wrote:
Consider:
```
struct S1 {
int A;
int B;
int foo() {
return(A+B);
}
}
struct S2 {
int A;
int B;
}
int fnAddS2(S2 X) {
return (X.A + X.B);
}
void main() {
import std.stdio : writeln;
S1 Var1 = S1(1,
Don't forget ``num % 2 == 0``.
None should matter, pretty much all production compilers within the last
30 years should recognize all forms of this and do the right thing.
I just need an even/odd functionality. Don't think D has a
built-in operator.
// Found this C code online.
int isEven(int num)
{
return !(num & 1);
}
// found this in std.functional.unaryFun
alias isEven = unaryFun!("(a & 1) == 0");
assert(isEven(2) && !isEven(1));
If
On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki)
Andrew Cattermole wrote:
Don't forget ``num % 2 == 0``.
None should matter, pretty much all production compilers within
the last 30 years should recognize all forms of this and do the
right thing.
Thanks. Fastest reply ever! And I
On Wed, Apr 26, 2023 at 11:07:39PM +, WhatMeWorry via Digitalmars-d-learn
wrote:
> On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki) Andrew
> Cattermole wrote:
> > Don't forget ``num % 2 == 0``.
> >
> > None should matter, pretty much all production compilers within the
> > last