summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--go.html.markdown8
-rw-r--r--lua.html.markdown15
-rw-r--r--objective-c.html.markdown10
3 files changed, 20 insertions, 13 deletions
diff --git a/go.html.markdown b/go.html.markdown
index 4db76a49..456f0c19 100644
--- a/go.html.markdown
+++ b/go.html.markdown
@@ -1,4 +1,4 @@
----
+---
name: Go
category: language
language: Go
@@ -71,7 +71,7 @@ func learnTypes() {
can include line breaks.` // same string type
// non-ASCII literal. Go source is UTF-8.
- g := 'Σ' // rune type, an alias for uint32, holds a UTF-8 code point
+ g := 'Σ' // rune type, an alias for uint32, holds a unicode code point
f := 3.14195 // float64, an IEEE-754 64-bit floating point number
c := 3 + 4i // complex128, represented internally with two float64s
@@ -251,7 +251,7 @@ func learnConcurrency() {
fmt.Println(<-c, <-c, <-c) // channel on right, <- is "receive" operator.
cs := make(chan string) // another channel, this one handles strings.
- cc := make(chan chan string) // a channel of channels.
+ cc := make(chan chan string) // a channel of string channels.
go func() { c <- 84 }() // start a new goroutine just to send a value
go func() { cs <- "wordy" }() // again, for cs this time
// Select has syntax like a switch statement but each case involves
@@ -259,7 +259,7 @@ func learnConcurrency() {
// that are ready to communicate.
select {
case i := <-c: // the value received can be assigned to a variable
- fmt.Println("it's a", i)
+ fmt.Printf("it's a %T", i)
case <-cs: // or the value received can be discarded
fmt.Println("it's a string")
case <-cc: // empty channel, not ready for communication.
diff --git a/lua.html.markdown b/lua.html.markdown
index 7325a1cf..369de908 100644
--- a/lua.html.markdown
+++ b/lua.html.markdown
@@ -125,6 +125,9 @@ f = function (x) return x * x end
-- And so are these:
local function g(x) return math.sin(x) end
+local g = function(x) return math.xin(x) end
+-- Equivalent to local function g(x)..., except referring
+-- to g in the function body won't work as expected.
local g; g = function (x) return math.sin(x) end
-- the 'local g' decl makes g-self-references ok.
@@ -133,6 +136,10 @@ local g; g = function (x) return math.sin(x) end
-- Calls with one string param don't need parens:
print 'hello' -- Works fine.
+-- Calls with one table param don't need parens
+-- either (more on tables below):
+print {} -- Works fine too.
+
----------------------------------------------------
-- 3. Tables.
@@ -203,7 +210,7 @@ f2 = {a = 2, b = 3}
metafraction = {}
function metafraction.__add(f1, f2)
- sum = {}
+ local sum = {}
sum.b = f1.b * f2.b
sum.a = f1.a * f2.b + f2.a * f1.b
return sum
@@ -266,7 +273,7 @@ eatenBy = myFavs.animal -- works! thanks, metatable
Dog = {} -- 1.
function Dog:new() -- 2.
- newObj = {sound = 'woof'} -- 3.
+ local newObj = {sound = 'woof'} -- 3.
self.__index = self -- 4.
return setmetatable(newObj, self) -- 5.
end
@@ -301,7 +308,7 @@ mrDog:makeSound() -- 'I say woof' -- 8.
LoudDog = Dog:new() -- 1.
function LoudDog:makeSound()
- s = self.sound .. ' ' -- 2.
+ local s = self.sound .. ' ' -- 2.
print(s .. s .. s)
end
@@ -322,7 +329,7 @@ seymour:makeSound() -- 'woof woof woof' -- 4.
-- If needed, a subclass's new() is like the base's:
function LoudDog:new()
- newObj = {}
+ local newObj = {}
-- set up newObj
self.__index = self
return setmetatable(newObj, self)
diff --git a/objective-c.html.markdown b/objective-c.html.markdown
index 9e9f43e7..926a4a0d 100644
--- a/objective-c.html.markdown
+++ b/objective-c.html.markdown
@@ -160,7 +160,7 @@ int main (int argc, const char * argv[])
int jj;
for (jj=0; jj < 4; jj++)
{
- NSLog(@"%d,", jj++);
+ NSLog(@"%d,", jj);
} // => prints "0,"
// "1,"
// "2,"
@@ -223,7 +223,7 @@ int main (int argc, const char * argv[])
// }
// -/+ (type) Method declarations;
// @end
-@interface MyClass : NSObject <MyCustomProtocol>
+@interface MyClass : NSObject <MyProtocol>
{
int count;
id data;
@@ -241,14 +241,14 @@ int main (int argc, const char * argv[])
+ (NSString *)classMethod;
// - for instance method
-- (NSString *)instanceMethodWithParmeter:(NSString *)string;
+- (NSString *)instanceMethodWithParameter:(NSString *)string;
- (NSNumber *)methodAParameterAsString:(NSString*)string andAParameterAsNumber:(NSNumber *)number;
@end
// Implement the methods in an implementation (MyClass.m) file:
-@implementation UserObject
+@implementation MyClass
// Call when the object is releasing
- (void)dealloc
@@ -271,7 +271,7 @@ int main (int argc, const char * argv[])
return [[self alloc] init];
}
-- (NSString *)instanceMethodWithParmeter:(NSString *)string
+- (NSString *)instanceMethodWithParameter:(NSString *)string
{
return @"New string";
}