New User Trying Out Object - Class Companionship

object Person {

// class level functionality
val nEyes = 2
def canFly : Boolean = false
class Person (val name: String, val age : Int) {
//instance level functionality
def ageDoubler = age * 2
// def salaryDoubler(salary:Int) = salary*2

// companion design pattern

va1 person1 = new Person(“SriRama”, 27)
val person2 = new Person(“SitaRama”, 29)

There is an error in the instance saying the “expected class or object definition”

Need help here. Apologies if the question is repeated.

val is not a valid top-level identifier, that would work on a REPL or worksheet. Otherwise, you need to instantiate those inside another class / method just like a normal program; e.g. the main one: Scastie - An interactive playground for Scala.

Thank you @BalmungSan