Comp sci: type parameter

Tutoring computer science, terms are important. The tutor mentions type parameter.

The motivation for a type parameter is easiest to imagine with a strongly typed language like Java. Typically, such a language insists on knowing the type of an argument before it receives it.

Yet, sometimes, a method will be defined to handle input of unspecified type. Then, an angle bracketed expression such as <T> will be in the method signature, meaning it can accept arbitrary types.

Internally, the method may use “if” conditions to determine how to handle the input, according to its type. Depending on the language, other ways, such as redirecting the input to a specific method based on the type it’s discovered to be, may also be used.

The word generic is typically used to refer to classes, methods, or functions whose definitions include type parameters. Generic may also refer to the inputs, unknown presently, that will be passed to the code.

Source:

tutorialspoint.com

docs.microsoft.com

docs.oracle.com

python.org

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Leave a Reply