March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -0,0 +1,8 @@
( ( resolution
= (x=)
(y=)
(new=.!arg:(?(its.x),?(its.y)))
)
& new$(resolution,640,480):?VGA
& new$(resolution,1920,1080):?1080p
& out$("VGA: horizontal " !(VGA..x) " vertical " !(VGA..y)));

View file

@ -1,7 +1,7 @@
@implementation MyClass
// Was not declared because init is defined in NSObject
- init
- (id)init
{
if (self = [super init])
variable = 0;

View file

@ -3,6 +3,3 @@ MyClass *mc = [[MyClass alloc] init];
// Sending a message
[mc variable];
// Releasing it. When its reference count goes to zero, it will be deallocated
[mc release];

View file

@ -1,7 +1,7 @@
class Camel { has Int $.humps = 1; }
my Camel $a .= new;
say $a.humps; # Automatically generated accessor method.
say $a.humps; # Automatically generated accessor method.
my Camel $b .= new: humps => 2;
say $b.humps;

View file

@ -1,5 +1,5 @@
class Butterfly {
has Int $!age; # The ! twigil makes it private.
has Int $!age; # With the ! twigil, no public accessor method is generated
has Str $.name;
has Str $.color;
has Bool $.wings;

View file

@ -1,19 +1,24 @@
/**
* This class implicitly includes a constructor which accepts an int and
* creates "val variable1: Int" with that value.
/** This class implicitly includes a constructor which accepts an Int and
* creates "val variable1: Int" with that value.
*/
class MyClass(variable1: Int) {
var variable2 = "asdf" // Another instance variable; a var this time
def this() = this(0) // An auxilliary constructor that instantiates with a default value
def myMethod = variable1 // A getter for variable1
class MyClass(val myMethod: Int) { // Acts like a getter, getter automatically generated.
var variable2 = "asdf" // Another instance variable; a public var this time
def this() = this(0) // An auxilliary constructor that instantiates with a default value
}
/**
* Demonstrate use of our example class.
*/
object Main extends Application {
val m = new MyClass()
val n = new MyClass(3)
println(m.myMethod) // prints 0
println(n.myMethod) // prints 3
object HelloObject {
val s = "Hello" // Not private, so getter auto-generated
}
/** Demonstrate use of our example class.
*/
object Call_an_object_method extends App {
val s = "Hello"
val m = new MyClass()
val n = new MyClass(3)
println(HelloObject.s) // prints "Hello" by object getterHelloObject
println(m.myMethod) // prints 0
println(n.myMethod) // prints 3
}