Content deleted Content added
m method.If->method. If - Fix a typo in one click Tags: Mobile edit Mobile web edit Advanced mobile edit |
Type hint |
||
Line 107:
class Example
{
Example() //
{
this(1); //
System.out.println("0-arg-cons");
}
Example(int a) //
{
System.out.println("1-arg-cons");
}
}
public static void main(String[] args)
{
Line 538 ⟶ 539:
<source lang="perl6">
class Person {
has Str $.first-name is required; #
# construction time (the . means "public").
has Str $.last-name is required; #
# construction time (a ! would mean "private").
has Int $.age is rw; #
# construction ('rw'), and is not required
# during the object instantiation.
#
#
method full-name { $!first-name.tc ~ " " ~ $!last-name.tc }
#
#
# by prepending its name with a !
method !has-age { self.age.defined }
#
method TWEAK {
if self!has-age && $!age < 18 { #
die "No person under 18";
}
Line 592 ⟶ 593:
class Person
{
private string $name;
public function __construct(string $name) : void
{
$this->name = $name;
}
public function getName() : string
{
return $this->name;
|