CS Electrical And Electronics
@cselectricalandelectronics

Expecting a top level declaration, How to fix this error in Kotlin?

All QuestionsCategory: KotlinExpecting a top level declaration, How to fix this error in Kotlin?
chetan shidling asked 4 years ago

Expecting a top level declaration

Expecting a top level declaration

Expecting a top level declaration

Expecting a top level declaration

Expecting a top level declaration

Expecting a top level declaration

Expecting a top level declaration

Expecting a top level declaration

Expecting a top level declaration

Expecting a top level declaration

Expecting a top level declaration

Function declaration must have a name

1 Answers
chetan shidling answered 4 years ago

Here is the code.
 
for main(args : Array<String>){
var nums = listOf(1,2,3,4)

for(i in nums)
{
println(i)
}
}
 
This type of error comes when you made mistake in writing the function name. See the first line of code, it should be fun, you wrote for.