fix: 修复 op_arrat.Has
This commit is contained in:
@ -70,13 +70,13 @@ func (a *Array[Bt]) Unique(arr Array[Bt]) []Bt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Has 查询一个值是否在列表里, 在的话, 返回首次出现的索引, 不在返回-1
|
// Has 查询一个值是否在列表里, 在的话, 返回首次出现的索引, 不在返回-1
|
||||||
func (a *Array[Bt]) Has(arr Array[Bt], input Bt) int {
|
func (a *Array[Bt]) Has(input Bt) int {
|
||||||
for idx := 0; idx < len(arr.value); idx++ {
|
for idx := 0; idx < len(a.value); idx++ {
|
||||||
if reflect.TypeOf(arr.value[idx]).String() != reflect.TypeOf(input).String() {
|
if reflect.TypeOf(a.value[idx]).String() != reflect.TypeOf(input).String() {
|
||||||
// 类型不同
|
// 类型不同
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
sourceByte, _ := json.Marshal(arr.value[idx])
|
sourceByte, _ := json.Marshal(a.value[idx])
|
||||||
inputByte, _ := json.Marshal(input)
|
inputByte, _ := json.Marshal(input)
|
||||||
if string(sourceByte) != string(inputByte) {
|
if string(sourceByte) != string(inputByte) {
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user