Q:

How to destruct a grpc message in kotlin?

I want to destruct a grpc message like this.
message AskOrUpdateQuestionRequest {
   int64 user_id = 1;
   int64 product_id = 2;
   core.model.QuestionProfile question = 3;
}

message QuestionProfile {
   int64 id = 1;
   Question.Status status = 2;
   Question.Type type = 3;
   string title = 4; 
}

I try to destruct this object? (grpc message) in kotlin 
   val  (title) = request.question

However, it failed with an error.

Destructuring declaration initializer of type QuestionModelProtos.QuestionProfile! must have a 'component1()' function

How can I make that work
Hopefully that makes sense.

SOLVED : @Alex Filatov 's answer helped me solve the problem.

A:

val (title) = request.question compiles to val title = request.question.component1(). Protobuf classes don't have componentX() methods, so you need to add them:
operator fun QuestionModelProtos.QuestionProfile.component1() = this.title

