mirror of
https://github.com/tursom/GoCollections.git
synced 2025-03-16 19:10:31 +08:00
18 lines
452 B
Go
18 lines
452 B
Go
|
package util
|
||
|
|
||
|
import (
|
||
|
"github.com/tursom/GoCollections/collections"
|
||
|
"github.com/tursom/GoCollections/exceptions"
|
||
|
"github.com/tursom/GoCollections/lang"
|
||
|
)
|
||
|
|
||
|
func AsList[T lang.Object](arr []T) collections.List[T] {
|
||
|
return &arrayList[T]{arr}
|
||
|
}
|
||
|
|
||
|
func CheckedGet[T any](array []T, index int) (T, exceptions.Exception) {
|
||
|
return exceptions.CatchIndexOutOfBound(func() T {
|
||
|
return array[index]
|
||
|
}, exceptions.DefaultExceptionConfig().AddSkipStack(3))
|
||
|
}
|