Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d4189ab

Browse filesBrowse files
committed
Merge branch 'ustinvaskin-upd-range-toString-ternary'
2 parents 70826e6 + e200917 commit d4189ab
Copy full SHA for d4189ab

File tree

Expand file treeCollapse file tree

2 files changed

+10
-11
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-11
lines changed

‎__tests__/Range.ts

Copy file name to clipboardExpand all lines: __tests__/Range.ts
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,11 @@ describe('Range', () => {
212212
.toArray()
213213
).toEqual([1, 2]);
214214
});
215+
216+
it('toString', () => {
217+
expect(Range(0, 0).toString()).toBe('Range []');
218+
expect(Range(0, 3).toString()).toBe('Range [ 0...3 ]');
219+
expect(Range(0, 10, 2).toString()).toBe('Range [ 0...10 by 2 ]');
220+
expect(Range(10, 0, -2).toString()).toBe('Range [ 10...0 by -2 ]');
221+
});
215222
});

‎src/Range.js

Copy file name to clipboardExpand all lines: src/Range.js
+3-11Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,9 @@ export class Range extends IndexedSeq {
4545
}
4646

4747
toString() {
48-
if (this.size === 0) {
49-
return 'Range []';
50-
}
51-
return (
52-
'Range [ ' +
53-
this._start +
54-
'...' +
55-
this._end +
56-
(this._step !== 1 ? ' by ' + this._step : '') +
57-
' ]'
58-
);
48+
return this.size === 0
49+
? 'Range []'
50+
: `Range [ ${this._start}...${this._end}${this._step !== 1 ? ' by ' + this._step : ''} ]`;
5951
}
6052

6153
get(index, notSetValue) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.