This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class State { | |
bool aisatu = false; | |
int onigiriPrice = 100; | |
} | |
var state = new State(); | |
void onMessage(String message) { | |
state = updateState(state, message); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool aisatu = false; | |
int onigiriPrice = 100; | |
void onMessage(String message) { | |
switch (message) { | |
case "こんにちは": | |
onAisatu(); | |
return; | |
case "おにぎり3個ください": | |
onOnigiriRequest(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Buyability isBuyable2(request) { | |
// ログインしていない | |
if (!isLoggedIn(request)) { | |
var result = new Buyability(); | |
result.buyable = false; | |
result.reason = "login"; | |
return result; | |
} | |
// 在庫がないし再入荷もできない |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Buyability isBuyable(request) { | |
var result = new Buyability(); | |
// ログインしているか | |
if (isLoggedIn(request)) { | |
// 在庫があるか | |
if (hasStock(request)) { | |
// お金は足りているか | |
if (hasMoney(request)) { | |
result.buyable = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Tweet> tweets(String uid, List<Follow> follows, List<Tweet> tweets, | |
List<ReTweet>reTweets) { | |
var result = <Tweet>[]; | |
// フォローしているユーザのUserIDを抽出 | |
var followUserIDs = getFollowUserIDs(follows, uid); | |
// フォローしているユーザのTweetを抽出 | |
result.addAll(getTweets(followUserIDs, tweets)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// followは全ユーザのフォロー・フォロワーの関係が入っているリスト | |
List<Tweet> tweets(String uid, List<Follow> follows, List<Tweet> tweets, | |
List<ReTweet>reTweets) { | |
var result = <Tweet>[]; | |
// フォローしているユーザのUserIDを抽出 | |
var followUserIDs = <String>[]; | |
for (var follow in follows) { | |
if (follow.from != uid) { | |
followUserIDs.add(follow.to); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// followは全ユーザのフォロー・フォロワーの関係が入っているリスト | |
List<Tweet> tweets(String uid, List<Follow> follows, List<Tweet> tweets, | |
List<ReTweet>reTweets) { | |
var result = <Tweet>[]; | |
// フォローしているユーザのTweetを抽出 | |
for (var follow in follows) { | |
// 自分がフォローしている人だけを通す | |
if (follow.from != uid) { | |
continue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// followは全ユーザのフォロー・フォロワーの関係が入っているリスト | |
List<Tweet> tweets(String uid, List<Follow> follows, List<Tweet> tweets, | |
List<ReTweet>reTweets) { | |
var result = <Tweet>[]; | |
for (var follow in follows) { | |
// 自分がフォローしている人だけを通す | |
if (follow.from != uid) { | |
continue; | |
} | |
// フォローしているユーザのTweetを抽出 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Original **/ | |
void method1() { | |
var fuga = hoge(); // 何かしらの複雑な処理 | |
method2(); | |
} | |
void method2() { | |
var fuga = hoge(); // 何かしらの複雑な処理 | |
method3(); | |
} |
NewerOlder