On Friday, 7 December 2012 at 14:21:51 UTC, Nick Treleaven wrote:
On 03/12/2012 14:22, Nick Treleaven wrote:
Most programmers would probably just pollute the existing
scope:
auto x = "thing" in arr;
if (x && *x == 45)
{
...
}
I expect this is because wrapping the above in {} for a new
sc
On 03/12/2012 14:22, Nick Treleaven wrote:
Most programmers would probably just pollute the existing scope:
auto x = "thing" in arr;
if (x && *x == 45)
{
...
}
I expect this is because wrapping the above in {} for a new scope is
just too ugly, introducing more nesting and indentation.
It
On 03/12/2012 20:17, Rob T wrote:
On Monday, 3 December 2012 at 14:22:28 UTC, Nick Treleaven wrote:
Most programmers would probably just pollute the existing scope:
auto x = "thing" in arr;
if (x && *x == 45)
{
...
}
You can always wrap it inside its own scope
Yes, that's why I wrote:
On Monday, 3 December 2012 at 14:22:28 UTC, Nick Treleaven wrote:
Most programmers would probably just pollute the existing scope:
auto x = "thing" in arr;
if (x && *x == 45)
{
...
}
You can always wrap it inside its own scope
main()
{
// temp scope
{
auto x = "thing" in arr;
On 02/12/2012 15:09, js.mdnq wrote:
Can this be made to work in D?
Error in D, x not found:
if (auto x = "thing" in arr && x == 45)
{
}
Works:
if (auto x = "thing" in arr)
if (x == 45)
{
}
Most programmers would probably just pollute the existing scope:
auto x = "thing" in
On Sunday, 2 December 2012 at 15:09:17 UTC, js.mdnq wrote:
Can this be made to work in D?
Error in D, x not found:
if (auto x = "thing" in arr && x == 45)
{
}
You can't have both a declaration and expression in an
if-statement.
http://dlang.org/statement.html#IfStatement
IfStatement:
And no, it cannot be made to work, because the grammar would be
ambiguous:
if (auto x = y && z)
Does this mean?
if (auto x = (y && z))
or
if (auto x = y)
if (x && z)
You could make it work with new syntax, but given you can just
use two if-statements, I don't see any point.
Can this be made to work in D?
Error in D, x not found:
if (auto x = "thing" in arr && x == 45)
{
}
Works:
if (auto x = "thing" in arr)
if (x == 45)
{
}