Kotlin Three 投稿指北
2016-07-15 本文已影响106人
哦好么人
![](https://img.haomeiwen.com/i1276113/844c728d306293b3.jpg)
创建 Kotlin Three 这个专题的时候,为了让保证文章的质量,我认为有必要为 Kotlin Three 提供一个尽量公开透明的投稿指北。
同时为了突出 Kotlin 语言的特性,这份指北是用 Kotlin 语言描述的。
fun User.contribute(post: Post): String {
reviewPost(KTPost(this, post), reviewRules)
return "Welcome"
}
val reviewRules = { post: KTPost ->
(isOriginal(post) || isTranslated(post)) && isGoodTypesetting(post) && looksGood(post)
}
open class User
open class Post(val creator: User, val content: String)
class KTPost(val contributor: User, post: Post) : Post(post.creator, post.content)
val posts = mutableListOf<KTPost>()
private val reviewer = User()
private fun reviewPost(post: KTPost, isGood: (post: KTPost) -> Boolean) =
if (isGood(post)) posts.add(post) else print("What a pity!!!")
private fun isOriginal(post: KTPost) = post.creator == post.contributor
private fun isTranslated(post: KTPost) = post.creator == post.contributor
private fun isGoodTypesetting(post: KTPost) = ChineseCopywritingGuidelines().mersure(post.content)
private fun looksGood(post: KTPost) = reviewer.value(post.contributor)
class ChineseCopywritingGuidelines(url: String = "https://github.com/sparanoid/chinese-copywriting-guidelines")
最后,欢迎投稿 Kotlin Three