Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class State {
bool aisatu = false;
int onigiriPrice = 100;
var state = new State();
void onMessage(String message) {
state = updateState(state, message);
State updateState(State _state, String message) {
switch (message) {
case "こんにちは":
return onAisatu(_state);
case "おにぎり3個ください":
return onOnigiriRequest(_state);
State onAisatu(State _state) {
return new State()
..onigiriPrice = _state.onigiriPrice
..aisatu = true;
State onOnigiriRequest(State _state) {
if (_state.aisatu) {
var sum = _state.onigiriPrice * 3;
print("$sum 円です");
return new State()
..onigiriPrice = _state.onigiriPrice
..aisatu = false;
return _state;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.