diff options
| author | Adam <adam@adambard.com> | 2015-10-19 14:28:03 +0800 | 
|---|---|---|
| committer | Adam <adam@adambard.com> | 2015-10-19 14:28:03 +0800 | 
| commit | e6573af645792cb434a16440f60cce8935fea95c (patch) | |
| tree | a3ac540a41f977dcbda046c8faa332cd8864f2b3 /hack.html.markdown | |
| parent | 6af01029e450fd2f82f0d056806ccb63a6e48ec9 (diff) | |
| parent | ba5f3ebc112b52797a9a21fdbba1846885feac2c (diff) | |
Merge branch 'master' of github.com:adambard/learnxinyminutes-docs
Diffstat (limited to 'hack.html.markdown')
| -rw-r--r-- | hack.html.markdown | 27 | 
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"      // | 
