泛型可以让同一个函数处理不同类型的数据,而不需要为每种类型重写代码。

Generics allow the same function to handle different data types without rewriting code for each one.

▼点击显示答案

Generics allow the same function to handle different data types without rewriting code for each one.

Generics 是 generic 的复数形式,generic 来自希腊语词根 "gen-"(表示"种类、类型")和后缀 "-eric"(构成形容词),原意为"通用的、一般的"。 在编程术语中,generics 指"泛型",是一种允许在定义函数、类等时使用类型参数的技术,使代码能够处理多种数据类型而不需要为每种类型单独编写实现。

在 App 中完整学习这张卡片

在 App 中学习