with (auto p = new ...)
Freddy via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Sep 26 13:04:49 PDT 2014
On Friday, 26 September 2014 at 19:59:56 UTC, Freddy wrote:
> 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é
> have you tried this?
> ---
> import std.stdio;
>
> struct myStruct{
> int c=299792458;
> }
>
> void main(){
> with(new myStruct()){
> writeln(c);
> }
> }
> ---
opps, sorry I misread the quesion.
More information about the Digitalmars-d-learn
mailing list