On Friday, 10 May 2024 at 16:33:53 UTC, Nick Treleaven wrote:
Arrays evaluate to true in boolean conditions if their `.ptr`
field is non-null. This is bug-prone and I hope we can remove
this in the next edition.
...
A string literal's `.ptr` field is always non-null, because it
is null-termina
On Friday, 10 May 2024 at 15:23:39 UTC, Andy Valencia wrote:
On Friday, 10 May 2024 at 03:07:43 UTC, Steven Schveighoffer
wrote:
Yes, we say that a type has "truthiness" if it can be used in
a condition (`while`, `if`, `assert`, etc).
So if I may ask for one more small clarification... WRT
"t
On Friday, 10 May 2024 at 03:07:43 UTC, Steven Schveighoffer
wrote:
Yes, we say that a type has "truthiness" if it can be used in a
condition (`while`, `if`, `assert`, etc).
So if I may ask for one more small clarification... WRT
"truthiness", I've observed that empty arrays are treated as
fa
On Friday, 10 May 2024 at 01:00:09 UTC, Andy Valencia wrote:
On Friday, 10 May 2024 at 00:40:01 UTC, Meta wrote:
Yes. The reason for this is that it avoids having to
essentially do the same check twice. If `in` returned a bool
instead of a pointer, after checking for whether the element
exists
On Friday, 10 May 2024 at 00:40:01 UTC, Meta wrote:
Yes. The reason for this is that it avoids having to
essentially do the same check twice. If `in` returned a bool
instead of a pointer, after checking for whether the element
exists (which requires searching for the element in the
associative
On Friday, 10 May 2024 at 00:18:16 UTC, Andy Valencia wrote:
tst7.d(6): Error: cannot implicitly convert expression `e in
this.members` of type `bool*` to `bool`
tst7.d(15): Error: template instance `tst7.Foo!uint` error
instantiating
I'm getting this for this bit of source (trimmed from the
tst7.d(6): Error: cannot implicitly convert expression `e in
this.members` of type `bool*` to `bool`
tst7.d(15): Error: template instance `tst7.Foo!uint` error
instantiating
I'm getting this for this bit of source (trimmed from the bigger
code). I switched to this.members.get(e, false) and th
On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:
[1] https://dlang.org/spec/expression.html#is_expression
Thanks
On Fri, Aug 07, 2020 at 09:02:03PM +, Per Nordlöw via Digitalmars-d-learn
wrote:
> On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:
> > [1] https://dlang.org/spec/expression.html#is_expression
>
> I bet there a several places in Phobos where this feature isn't but
> could be use
On Friday, 7 August 2020 at 21:02:03 UTC, Per Nordlöw wrote:
On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:
[1] https://dlang.org/spec/expression.html#is_expression
I bet there a several places in Phobos where this feature isn't
but could be used.
I feel same. That there's a
On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:
[1] https://dlang.org/spec/expression.html#is_expression
I bet there a several places in Phobos where this feature isn't
but could be used.
On Thursday, 6 August 2020 at 22:24:43 UTC, Paul Backus wrote:
[1] https://dlang.org/spec/expression.html#is_expression
Thanks
On Thursday, 6 August 2020 at 21:50:06 UTC, Per Nordlöw wrote:
I just discovered that the is-operator can be used as in
template ElementType(R)
{
static if (is(typeof(R.init.front.init) T))
alias ElementType = T;
else
alias ElementType = void;
}
. Very powerful. Is this
I just discovered that the is-operator can be used as in
template ElementType(R)
{
static if (is(typeof(R.init.front.init) T))
alias ElementType = T;
else
alias ElementType = void;
}
. Very powerful. Is this documented?
On Thursday, 6 August 2020 at 21:50:06 UTC, Per Nordlöw wrote:
I just discovered that the is-operator can be used as in
...
Doh, title should of course be
I just discovered an alternative use of `is`-expressions.
On Sunday, August 02, 2015 21:51:48 Ali Çehreli via Digitalmars-d-learn wrote:
> Is my understanding below correct? Does any documentation need updating?
>
> Operator precedence table lists !in as an operator:
>
>http://wiki.dlang.org/Operator_precedence
>
> Operator overloading documentation d
Is my understanding below correct? Does any documentation need updating?
Operator precedence table lists !in as an operator:
http://wiki.dlang.org/Operator_precedence
Operator overloading documentation does not mention it:
http://dlang.org/operatoroverloading.html#binary
However, 'a !in b
On 09/24/2011 01:18 PM, Andrej Mitrovic wrote:
> Information about overloading opIn and opIn_r is missing from the
> docs, so I'm writing that section. But I don't know what is the formal
> name of this operator so I can put it in the title. Maybe I should
> just name the tit
On Saturday, September 24, 2011 20:37:45 Andrej Mitrovic wrote:
> Oh wait, I've just realized that opIn is actually the old way of using
> that operator. The new way is using opBinary and string matching
> instead. This is already described in the docs.
>
> I guess opIn and opIn_r are going away?
Oh wait, I've just realized that opIn is actually the old way of using
that operator. The new way is using opBinary and string matching
instead. This is already described in the docs.
I guess opIn and opIn_r are going away?
Information about overloading opIn and opIn_r is missing from the
docs, so I'm writing that section. But I don't know what is the formal
name of this operator so I can put it in the title. Maybe I should
just name the title "Overloading the In Operator"?
On 03/04/2011 10:41 AM, Magnus Lie Hetland wrote:
On 2011-03-04 18:08:08 +0100, spir said:
Didn't even know 'in' can be defined with opBinary...
I use opIn_r ('r' for right side, since the container stand on the
right of the expression) everywhere, and it works fine.
Huh. Cool. Works like a c
On 2011-03-04 18:08:08 +0100, spir said:
Didn't even know 'in' can be defined with opBinary...
I use opIn_r ('r' for right side, since the container stand on the
right of the expression) everywhere, and it works fine.
Huh. Cool. Works like a charm. Seems cleaner like the opBinaryRight
soluti
On 03/04/2011 05:01 PM, Magnus Lie Hetland wrote:
I'm writing a collection with functionality for membership checking. I thought
it would be nice to use the "in" operator. In the docs for std.collections I
surmise that this is the standard way to go. From the source code, I
Magnus Lie Hetland wrote:
On 2011-03-04 17:06:29 +0100, Mafi said:
If you try to use it in the manner of `something in
classWhichDefinesThisOpBinary` then it doesn't work because operator
overloading normally overloads on the left operand (ie something). Use
opBinaryRight(string op)(...)
On 2011-03-04 17:06:29 +0100, Mafi said:
If you try to use it in the manner of `something in
classWhichDefinesThisOpBinary` then it doesn't work because operator
overloading normally overloads on the left operand (ie something). Use
opBinaryRight(string op)(...) if(...) to get it working.
Aa
Am 04.03.2011 17:01, schrieb Magnus Lie Hetland:
I'm writing a collection with functionality for membership checking. I
thought it would be nice to use the "in" operator. In the docs for
std.collections I surmise that this is the standard way to go. From the
source code, I see the
I'm writing a collection with functionality for membership checking. I
thought it would be nice to use the "in" operator. In the docs for
std.collections I surmise that this is the standard way to go. From the
source code, I see there's no special opIn, but that it can be
Works in D2, but not in D1. Perhaps this is only a D2 feature?
On 12/26/10, Jacek Nowak wrote:
> Hi, I don't know if it's the right place for this, I prefer forums to
> newsgroups. Anyway, I am learning D and trying to work with associative
> arrays.
>
> Code (I'm using v1.065 of the DMD compiler
Jacek Nowak:
> Hi, I don't know if it's the right place for this, I prefer forums to
> newsgroups.
This is the right place. And I think you need to get used to the newsgroups.
There is also the IRC #D channel.
> now, according to http://digitalmars.com/d/1.0/expression.html
> "The !in express
Hi, I don't know if it's the right place for this, I prefer forums to
newsgroups. Anyway, I am learning D and trying to work with associative arrays.
Code (I'm using v1.065 of the DMD compiler):
int[char[]] arr;
if ("foo" in arr)
{
};
if ("foo" !in arr) // if (!("foo" in arr)) obvi
31 matches
Mail list logo