Variant of 'with' which returns target object

2016-06-06 Thread Eduardo Cavazos
Hello, Here's a simple class: class Point { has $.x is rw; has $.y is rw; } 'with' seems to return the result of evaluating the block. E.g. this expression will return a Point: with Point.new { .x = 10; $_; } Whereas this will return 10: with Point.new { .x = 10; } Is there a way

Re: Variant of 'with' which returns target object

2016-06-06 Thread Eduardo Cavazos
On Mon, Jun 6, 2016 at 2:08 PM, yary wrote: > > For your particular case, would it be sufficient to set the values in > the constructor? > > with Point.new( :x(10) ) { .say } > # says "Point.new(x => 10, y => Any)" > Normally, that would be a good way to construct the Points in my example. I'm

Re: Variant of 'with' which returns target object

2016-06-06 Thread Eduardo Cavazos
ew(label => 'bcd').&cascade: { .clicked.tap({ .sensitive = False; $button.sensitive = True; }); }; $button = GTK::Simple::Button.new(label => 'cde').&cascade: { .clicked.tap({ $app.exit; }); } ); .border-width = 20; .run; }; On Mon, Jun

Re: Variant of 'with' which returns target object

2016-06-06 Thread Eduardo Cavazos
Here's another example from gtk-simple: https://github.com/perl6/gtk-simple/blob/d1fcc6efe1da3fd88a26b4328d6537c58607dee7/examples/07-text.pl6 Written with cascade: https://gist.github.com/dharmatech/b8e8a71da8149382f192603e1b92d9b8 Ed On Mon, Jun 6, 2016 at 4:12 PM, Eduardo Cavazos