我需要创建一个函数,它需要实现以下功能:
我能想到的唯一方法是反转切片,然后比较切片和反转后的切片。
有没有更好的方法来做到这一点,既具有良好的语法又更有效率?
returns true if all elements in a slice are equal (they will all be the same type)
returns false if any elements in a slice are different
我能想到的唯一方法是反转切片,然后比较切片和反转后的切片。
有没有更好的方法来做到这一点,既具有良好的语法又更有效率?