From bc404ec6f8850be3f1512dc36b49af0bdeec6449 Mon Sep 17 00:00:00 2001 From: Gagan Rai <43465333+fuzzknob@users.noreply.github.com> Date: Wed, 27 Feb 2019 19:46:04 +0545 Subject: [PATCH] Fixes (#22) * Fixed usage of for-in loop in iterator example. * Fixed typos. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5135d37..d3ab1c7 100644 --- a/README.md +++ b/README.md @@ -1032,7 +1032,7 @@ function* fibonacci(): IterableIterator { function print(n: number) { let i = 0; - for (const fib in fibonacci()) { + for (const fib of fibonacci()) { if (i++ === n) break; console.log(fib); } @@ -1070,7 +1070,7 @@ itiriri(fibonacci()) ### Use getters and setters TypeScript supports getter/setter syntax. -Using getters and setters to access data from objects that encapsulate behavior could be better that simply looking for a property on an object. +Using getters and setters to access data from objects that encapsulate behavior could be better than simply looking for a property on an object. "Why?" you might ask. Well, here's a list of reasons: - When you want to do more beyond getting an object property, you don't have to look up and change every accessor in your codebase. @@ -1686,7 +1686,7 @@ class HttpRequester { This is a scary term for a very simple concept. It's formally defined as "If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may substitute objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.)." That's an even scarier definition. -The best explanation for this is if you have a parent class and a child class, then the base class and child class can be used interchangeably without getting incorrect results. This might still be confusing, so let's take a look at the classic Square-Rectangle example. Mathematically, a square is a rectangle, but if you model it using the "is-a" relationship via inheritance, you quickly get into trouble. +The best explanation for this is if you have a parent class and a child class, then the parent class and child class can be used interchangeably without getting incorrect results. This might still be confusing, so let's take a look at the classic Square-Rectangle example. Mathematically, a square is a rectangle, but if you model it using the "is-a" relationship via inheritance, you quickly get into trouble. **Bad:**