iari
05/27/2020, 5:57 AMfun sendSimpleMessage(
op: SimpleMailMessage.() -> Unit
) {
val message = SimpleMailMessage().apply(op)
mailSender.send(message)
}
A part of the MailMessage interface is the method:
public void setSubject(String subject)
So now on the calling site I have
mail.sendSimpleMessage {
setTo(address)
subject = "Test Email" // compiler warning
//setSubject("Test Email") <--- this does work though
....
}
And the comp0iler says:
Val cannot be reassignedBut this isn't a val - the compiler should translate it to setSubject - thats also what the IDE suggests (ctrl-click brings me to the interface method) I don't understand, what the compiler thinks that 'subject' is supposed to be .... certainly not a val, since this shouldn't be kotlin code Any hints what could be going on there?