Skip to content

Commit 7061c43

Browse files
committed
refactor: early return
1 parent 1cb653a commit 7061c43

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

dsl/types/types.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ func (t *arrayType) String() string {
115115
}
116116

117117
func (t *arrayType) InstanceOf(t2 Type) bool {
118-
if array, ok := t2.(*arrayType); ok {
119-
return t.arg.InstanceOf(array.arg)
118+
array, ok := t2.(*arrayType)
119+
if !ok {
120+
return false
120121
}
121-
return false
122+
return t.arg.InstanceOf(array.arg)
122123
}
123124

124125
// ===================== Object type ===================== //
@@ -137,10 +138,11 @@ func (t *objectType) String() string {
137138
}
138139

139140
func (t *objectType) InstanceOf(t2 Type) bool {
140-
if array, ok := t2.(*objectType); ok {
141-
return t.arg.InstanceOf(array.arg)
141+
object, ok := t2.(*objectType)
142+
if !ok {
143+
return false
142144
}
143-
return false
145+
return t.arg.InstanceOf(object.arg)
144146
}
145147

146148
// ===================== Any type ===================== //

0 commit comments

Comments
 (0)