mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Spellcheck
This commit is contained in:
parent
77c4ddb522
commit
e7fe0b267a
@ -117,7 +117,7 @@ a = thisInt ^ thatInt; // Bitwise exclusive-or
|
||||
a += thisInt; // Addition-equals ( a = a + thisInt;)
|
||||
a *= thatInt; // Times-equals ( a = a * thatInt; )
|
||||
b &&= thatBool; // Logical-and-equals ( b = b && thatBool; )
|
||||
a <<= 3; // LEft-bit-shift-equals ( a = a << 10; )
|
||||
a <<= 3; // Left-bit-shift-equals ( a = a << 10; )
|
||||
// and many, many more.
|
||||
// Unlike other C family languages there are no
|
||||
// pre/post-increment/decrement operators like
|
||||
@ -190,7 +190,7 @@ if ( a % 3 == 0 ) {
|
||||
var maximum = if ( thisInt < thatInt ) then thatInt else thisInt;
|
||||
|
||||
// Select statements are much like switch statements in other languages
|
||||
// However, Select statements dont cascade like in C or Java
|
||||
// However, Select statements don't cascade like in C or Java
|
||||
var inputOption = "anOption";
|
||||
select( inputOption ){
|
||||
when "anOption" do writeln( "Chose 'anOption'" );
|
||||
@ -201,8 +201,6 @@ select( inputOption ){
|
||||
otherwise {
|
||||
writeln( "Any other Input" );
|
||||
writeln( "the otherwise case doesn't need a do if the body is one line" );
|
||||
writeln( "Oh, and when statements dont cascade like the case statements" );
|
||||
writeln( "of other languages" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,7 +244,7 @@ for x in 1..10 {
|
||||
// define an index set that can be iterated over.
|
||||
// Ranges are single dimensional
|
||||
// Domains can be multi-dimensional and can
|
||||
// represent indicies of different types as well.
|
||||
// represent indices of different types as well.
|
||||
// They are first-class citizen types, and can be assigned into variables
|
||||
var range1to10: range = 1..10; // 1, 2, 3, ..., 10
|
||||
var range2to11 = 2..11; // 2, 3, 4, ..., 11
|
||||
@ -452,7 +450,7 @@ writeln( myChangingArray );
|
||||
|
||||
// We can query the type of arguments to generic procedures
|
||||
// Here we define a procedure that takes two arguments of
|
||||
// the same type, yet we dont define what that type is.
|
||||
// the same type, yet we don't define what that type is.
|
||||
proc genericProc( arg1 : ?valueType, arg2 : valueType ): void {
|
||||
select( valueType ){
|
||||
when int do writeln( arg1, " and ", arg2, " are ints" );
|
||||
@ -620,10 +618,10 @@ class GenericClass {
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
// Note: We still have to put the the type as an argument, but we can
|
||||
// Note: We still have to put the type as an argument, but we can
|
||||
// default to the type of the other object using the query (?) operator
|
||||
// Further, we can take advantage of this to allow our copy constructor
|
||||
// to copy classes of different types
|
||||
// to copy classes of different types and cast on the fly
|
||||
proc GenericClass( other : GenericClass(?otherType),
|
||||
type classType = otherType ) {
|
||||
this.classDomain = other.classDomain;
|
||||
|
Loading…
Reference in New Issue
Block a user