Default arguments not carrying in to object creation


#1

I have my primary constructor created as follows, matching Listing 13.7

class Player(_name: String,
         var healthPoints: Int = 100,
         val isBlessed: Boolean,
         private val isImmortal: Boolean) {

I then try to create objects of type Player

val hero = Player("Madrigal", 100, false, false)
val npc = Player("Madrigal", true, false)

The hero object is created fine. IntelliJ gives an error for the npc object stating

None of the following functions can be called with the arguments supplied.
<init>(String) defined in Player
<init>(String, Int = ..., Boolean, Boolean) defined in Player

If I use named arguments then the default argument is applied for healthPoints

val npc = Player(name="Madrigal", isBlessed=true, isImmortal=false)

and no error is displayed. Is there a proper way to use the constructor variants?