summaryrefslogtreecommitdiffhomepage
path: root/hack.html.markdown
diff options
context:
space:
mode:
authorLari Kovanen <lari@kovanen.se>2015-12-09 13:25:01 +0100
committerLari Kovanen <lari@kovanen.se>2015-12-09 13:25:01 +0100
commit46d3c28a5fc341f3b8ef061e963adfc7c610263e (patch)
tree794df6f192a3875dc09d2710395048c5f405a806 /hack.html.markdown
parentdbfb19bb5779e84add18a19ebc36833e748e69d9 (diff)
parent1f76b2ad8c35b6c7e8ac2cc5dac8f20bc74f09ef (diff)
Merge remote-tracking branch 'adambard/master'
Diffstat (limited to 'hack.html.markdown')
-rw-r--r--hack.html.markdown27
1 files changed, 14 insertions, 13 deletions
diff --git a/hack.html.markdown b/hack.html.markdown
index 632fc705..b3d19f8e 100644
--- a/hack.html.markdown
+++ b/hack.html.markdown
@@ -2,6 +2,7 @@
language: Hack
contributors:
- ["Stephen Holdaway", "https://github.com/stecman"]
+ - ["David Lima", "https://github.com/davelima"]
filename: learnhack.hh
---
@@ -50,7 +51,7 @@ function identity(?string $stringOrNull) : ?string
class TypeHintedProperties
{
public ?string $name;
-
+
protected int $id;
private float $score = 100.0;
@@ -90,7 +91,7 @@ function openBox(Box<int> $box) : int
// Shapes
-//
+//
// Hack adds the concept of shapes for defining struct-like arrays with a
// guaranteed, type-checked set of keys
type Point2D = shape('x' => int, 'y' => int);
@@ -107,7 +108,7 @@ distance(
// Type aliasing
-//
+//
// Hack adds a bunch of type aliasing features for making complex types readable
newtype VectorArray = array<int, Vector<int>>;
@@ -141,7 +142,7 @@ function getRoadType() : RoadType
// Constructor argument promotion
-//
+//
// To avoid boilerplate property and constructor definitions that only set
// properties, Hack adds a concise syntax for defining properties and a
// constructor at the same time.
@@ -152,7 +153,7 @@ class ArgumentPromotion
private bool $isAwesome) {}
}
-class WithoutArugmentPromotion
+class WithoutArgumentPromotion
{
public string $name;
@@ -169,13 +170,13 @@ class WithoutArugmentPromotion
}
-// Co-oprerative multi-tasking
-//
-// Two new keywords "async" and "await" can be used to perform mutli-tasking
+// Co-operative multi-tasking
+//
+// Two new keywords "async" and "await" can be used to perform multi-tasking
// Note that this does not involve threads - it just allows transfer of control
async function cooperativePrint(int $start, int $end) : Awaitable<void>
{
- for ($i = $start; $i <= $end; $i++) {
+ for ($i = $start; $i <= $end; $i++) {
echo "$i ";
// Give other tasks a chance to do something
@@ -192,9 +193,9 @@ AwaitAllWaitHandle::fromArray([
// Attributes
-//
+//
// Attributes are a form of metadata for functions. Hack provides some
-// special built-in attributes that introduce useful behaviour.
+// special built-in attributes that introduce useful behaviour.
// The __Memoize special attribute causes the result of a function to be cached
<<__Memoize>>
@@ -247,7 +248,7 @@ class ConsistentBar extends ConsistentFoo
class InvalidFooSubclass extends ConsistentFoo
{
// Not matching the parent constructor will cause a type checker error:
- //
+ //
// "This object is of type ConsistentBaz. It is incompatible with this object
// of type ConsistentFoo because some of their methods are incompatible"
//
@@ -258,7 +259,7 @@ class InvalidFooSubclass extends ConsistentFoo
// Using the __Override annotation on a non-overriden method will cause a
// type checker error:
- //
+ //
// "InvalidFooSubclass::otherMethod() is marked as override; no non-private
// parent definition found or overridden parent is defined in non-<?hh code"
//