Kotlin Three 投稿指北

Kotlin Three 投稿指北_第1张图片

创建 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()

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

你可能感兴趣的:(Kotlin Three 投稿指北)