-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed handling tuples when they are part of union/intersection
- Loading branch information
Evgeniy Timokhov
committed
Mar 26, 2021
1 parent
4152e4d
commit fe888b5
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
type TwoItems = [number, number]; | ||
type FourItems = [number, number, number, number]; | ||
type TupleOrNumber = number | TwoItems | FourItems; | ||
|
||
function drawRoundRect(tupleOrNumber: TupleOrNumber): void { | ||
if (!Array.isArray(tupleOrNumber)) { | ||
console.log(tupleOrNumber.toExponential()); | ||
} else if (tupleOrNumber.length === 2) { | ||
const [first, second] = tupleOrNumber; | ||
console.log(first.toExponential(), second.toExponential()); | ||
} else if (tupleOrNumber.length === 4) { | ||
const [first, second, third, fourth] = tupleOrNumber; | ||
console.log(first.toExponential(), second.toExponential(), third.toExponential(), fourth.toExponential()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function drawRoundRect(tupleOrNumber) { | ||
if (!Array.isArray(tupleOrNumber)) { | ||
console.log(tupleOrNumber.toExponential()); | ||
} | ||
else if (tupleOrNumber.length === 2) { | ||
var first = tupleOrNumber[0], second = tupleOrNumber[1]; | ||
console.log(first.toExponential(), second.toExponential()); | ||
} | ||
else if (tupleOrNumber.length === 4) { | ||
var first = tupleOrNumber[0], second = tupleOrNumber[1], third = tupleOrNumber[2], fourth = tupleOrNumber[3]; | ||
console.log(first.toExponential(), second.toExponential(), third.toExponential(), fourth.toExponential()); | ||
} | ||
} |