swift list简单使用
2021-04-23 00:26
标签:and 使用 list ace 截取 random numbers bsp convert 1. 截取列表值 (前几个) /// let numbers = [1, 2, 3, 4, 5] /// print(numbers.prefix(2)) /// // Prints "[1, 2]" /// print(numbers.prefix(10)) /// // Prints "[1, 2, 3, 4, 5]" 2. 截取列表值 (后几个) /// let numbers = [1, 2, 3, 4, 5] /// print(numbers.suffix(2)) /// // Prints "[4, 5]" /// print(numbers.suffix(10)) /// // Prints "[1, 2, 3, 4, 5]" 3. 获取一个随机的元素 let numbers = [1, 2, 3, 4, 5] let number = numbers.randomElement() swift list简单使用 标签:and 使用 list ace 截取 random numbers bsp convert 原文地址:https://www.cnblogs.com/luobenpaidui/p/13273581.html