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
wrote:
>
On Mon, Jun 6, 2016 at 5:47 PM, yary wrote:
> GTK::Simple::Button.new(label => 'bcd').clicked. ...
whoops, that should be
with GTK::Simple::Button.new(label => 'bcd') {
.clicked.tap({ .sensitive = False; $button.sensitive =
True; });
}
alas I am on win
That's a nice & small answer. It does seem overkill for the gtk example...
use v6;
use GTK::Simple;
with GTK::Simple::App.new(title => 'abc') {
my $app = $_;
my $button;
.set-content:
GTK::Simple::VBox.new(
GTK::Simple::Button.new(label => 'bcd').clicked.tap({
Looks like I can get pretty close to what I was looking for with this
subroutine:
sub cascade ($obj, &proc) { proc($obj); $obj; }
Then, given the Point class again:
class Point { has $.x is rw; has $.y is rw; }
this:
(Point.new.&cascade: {.x = 10;}; Point.new.&cascade: {.y = 20;})
> On 06 Jun 2016, at 21:17, Eduardo Cavazos wrote:
>
> 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 w
On Mon, Jun 6, 2016 at 2:12 PM, Eduardo Cavazos wrote:
>
> with_alt Point.new { .x = 10; }
>
> would return a Point.
>
> And this:
>
> (with_alt Point.new {.x = 10}; with_alt Point.new {.y = 20})
For your particular case, would it be sufficient to set the values in
the constructor?
with
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
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