Skip to content

Commit 1bc93f1

Browse files
committed
Simplify nil conditionals
1 parent 3348b43 commit 1bc93f1

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/DataFrame/DataFrameInternal.class.st

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,17 @@ DataFrameInternal >> initialize: aPoint [
254254
{ #category : #accessing }
255255
DataFrameInternal >> numberOfColumns [
256256

257-
contents numberOfColumns isNil
258-
ifTrue: [ ^ 0 ].
259-
260-
^ contents numberOfColumns.
257+
contents numberOfColumns ifNil: [ ^ 0 ].
258+
259+
^ contents numberOfColumns
261260
]
262261

263262
{ #category : #accessing }
264263
DataFrameInternal >> numberOfRows [
265264

266-
contents numberOfRows isNil
267-
ifTrue: [ ^ 0 ].
268-
269-
^ contents numberOfRows.
265+
contents numberOfRows ifNil: [ ^ 0 ].
266+
267+
^ contents numberOfRows
270268
]
271269

272270
{ #category : #printing }

src/DataFrame/DataSeries.class.st

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ DataSeries >> collect: aBlock [
193193
{ #category : #enumerating }
194194
DataSeries >> collectWithNotNils: aBlock [
195195
"Applies aBlock to every non-nil element"
196+
196197
^ self collect: [ :each |
197-
each isNil ifTrue: [ nil ] ifFalse: [ aBlock value: each ]
198-
]
198+
each
199+
ifNil: [ nil ]
200+
ifNotNil: [ aBlock value: each ] ]
199201
]
200202

201203
{ #category : #'as yet unclassified' }
@@ -520,10 +522,8 @@ DataSeries >> removeNils [
520522
{ #category : #replacing }
521523
DataSeries >> replaceNilsWith: anObject [
522524
"Replaces nils inplace with anObject"
523-
524-
self withIndexDo: [ :ele :index |
525-
ele isNil
526-
ifTrue: [ self atIndex: index put: anObject ] ]
525+
526+
self withIndexDo: [ :ele :index | ele ifNil: [ self atIndex: index put: anObject ] ]
527527
]
528528

529529
{ #category : #replacing }

0 commit comments

Comments
 (0)