Yes, that is also working. As far as I remember (only my tablet
currently available) also this works:
Panel p;
with(p = new Panel ()) {}
Therefore it seems strange,the same does not work with auto.
Kind regards
André
On Tuesday, 23 September 2014 at 19:49:22 UTC, Graham Fawcett
wrote:
Sorry, I sent that last message before I intended to.
How about:
auto b = new Button(); with (b) {
...
}
'b' is explicitly outside of the scope of the 'with' block,
which may not be what you intended. But you could use more
braces to add an extra level of scope if that's an issue:
...
text = "blah";
{
auto b = new Button(); with (b) {
...
}
}
// b is no longer in scope
Graham
On Tuesday, 23 September 2014 at 15:19:59 UTC, Andre wrote:
Hi,
I just wonder why "with (auto p = new ...)" is not working.
It would be some syntax sugar in this scenario:
with (auto p = new Panel())
{
parent = this;
text = "bla";
with (auto b = new Button())
{
parent = p; // Here p is needed
text = "bla2";
}
}
source\app.d(8): Error: expression expected, not 'auto'
source\app.d(8): Error: found 'p' when expecting ')'
source\app.d(8): Error: found '=' instead of statement
...
Kind regards
André