answer

Returns the answer with the given name. Use this when the name is only known at run time, then check the answer's class or DecisionAnswer.kind to read its outcome.

Return

the answer with that name

Parameters

name

the question name

Throws

if this response has no answer with that name


fun <R : Any> answer(question: Question<R>): R

Returns the outcome for the given question, typed by the question. The question does not have to be the same object that built the response. The answer must have the question's name and kind, and a choice answer's options or a rating answer's levels must equal the question's, ids and descriptions both.

An answer holds no instructions, so a question whose instructions were reworded still matches. For a proposition that means only the name and kind are checked.

Each question class fixes its result type: a PropositionQuestionSpec is a Question<PropositionResult>, a ChoiceQuestionSpec is a Question<ClassificationResult> and a RatingQuestionSpec is a Question<RatingResult>. The lookup only returns an outcome from the answer class that matches the question's class, so the outcome always has type R.

Return

the outcome of that question

Parameters

question

the question whose answer to read

Throws

if this response has no answer with the question's name, the answer is of another kind, or the answer's options or levels differ from the question's