- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is "out" keyword in Kotlin?
"Out" keyword is extensively used in Kotlin generics. Its signature looks like this −
List<out T>
When a type parameter T of a class C is declared out, then C
Example
The following example demonstrates how you can use the "out" keyword in Kotlin −
fun main(args: Array<String>) { var objet1 = genericsExample<Int>(10) var objet2 = genericsExample<Double>(10.0) } // As generic type is declared as "out", // we can pass Int and Double also. class genericsExample<out T>(input:Any?) { init { println("I am getting called with the value "+input) } }
Output
It will produce the following output
I am getting called with the value 10 I am getting called with the value 10.0
- Related Articles
- What does 'by' keyword do in Kotlin?
- How does the reified keyword work in Kotlin?
- Difference between out and ref keyword in C#
- What is Keyword Streaming?
- What is volatile keyword in C++?
- What is "namespace" keyword in PHP?
- What is Keyword Driven Testing?
- What is the yield keyword in JavaScript?
- What is the const Keyword in C++?
- What is the Background keyword in Cucumber?
- What is the Example keyword in Cucumber?
- What is the use of "is" keyword in C#?
- Android imageView Zoom-in and Zoom-Out using Kotlin?
- What is the native keyword in Java for?
- What is the Scenario Outline keyword in Cucumber?

Advertisements