This file contains hidden or 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
| import kotlinx.serialization.* | |
| import kotlinx.serialization.internal.SerialClassDescImpl | |
| import java.lang.reflect.Field | |
| @Serializable | |
| class ByteArrayWapper(val byteArray: ByteArray) { | |
| @Serializer(forClass = ByteArrayWapper::class) | |
| companion object : KSerializer<ByteArrayWapper> { | |
| private val decoderField: Field = Class.forName("kotlinx.serialization.protobuf.ProtoBuf\$ProtobufReader") | |
| .getDeclaredField("decoder") |
This file contains hidden or 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
| fun main(): Unit = with(SomeBuilder) { | |
| SomeBuilder.getBuilder().setS2("2").setS1("1").buildSome() // ok | |
| SomeBuilder.getBuilder().setS1("1").setS2("2").buildSome() // ok | |
| SomeBuilder.getBuilder().setS1("1").buildSome() // error | |
| SomeBuilder.getBuilder().setS2("2").buildSome() // error | |
| SomeBuilder.getBuilder().buildSome() // もerror | |
| } | |
| class Some(val s1: String, val s2: String) |
This file contains hidden or 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
| package tsundb | |
| import com.squareup.moshi.Moshi | |
| import com.squareup.moshi.Types | |
| import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory | |
| import retrofit2.Call | |
| import retrofit2.Retrofit | |
| import retrofit2.converter.moshi.MoshiConverterFactory | |
| import retrofit2.http.GET | |
| import retrofit2.http.Path |
This file contains hidden or 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
| // ==UserScript== | |
| // @name 知乎隐私政策应对 | |
| // @description 不同意! | |
| // @match *://www.zhihu.com/* | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| var __t = 0; | |
| var __timer = setTimeout(function () { |
This file contains hidden or 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
| import java.util.AbstractCollection; | |
| import java.util.AbstractSet; | |
| import java.util.Arrays; | |
| import java.util.Collection; | |
| import java.util.Iterator; | |
| import java.util.Map; | |
| import java.util.NoSuchElementException; | |
| import java.util.Set; | |
| public class LinearProbingHashMap<K, V> implements Map<K, V> { |
This file contains hidden or 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
| fun main(args: Array<String>) { | |
| println(吔屎啦下划线地狱(127, 127, 128)) | |
| } | |
| fun 吔屎啦下划线地狱(______________: Int?, ____________: Int?, _____________: Int?) = ______________ === _____________ | |
| // 这道题目利用了 超长的下划线名称 和 Java自动装箱的破事 以及 出题者对回答者的诱导(如果有的话) 糊弄眼球转移注意力。 | |
| // 答案很简单: |
This file contains hidden or 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
| fun main(vararg args: String) { | |
| val str = "4" | |
| var i = 0 | |
| switch(str) { | |
| case("5") { i++; println("case(\"5\")"); 打断() } | |
| case("4") { i++; println("case(\"4\")") } | |
| case("3") { i++; println("case(\"3\")") } | |
| case("2") { i++; println("case(\"2\")"); 打断() } | |
| case("1") { i++; println("case(\"1\")") } | |
| } |
This file contains hidden or 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
| import Option.Some | |
| fun main(args: Array<String>) { | |
| println(Some({ a: Int -> a + 3 }).apply(Some(2))) | |
| // => Some(5) | |
| println(Some(2).apply(Some({ a: Int -> a + 3 }))) | |
| // => Some(5) | |
| val array = arrayOf<(Int) -> Int>({ it + 3 }, { it * 2 }) apply arrayOf(1, 2, 3) |
This file contains hidden or 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
| fun main(args: Array<String>) { | |
| val r = "hello" next ::length next ::double | |
| println(r) | |
| } | |
| fun length(s:String) = s.length | |
| fun double(i : Int) = 2 * i | |
| infix fun <T, R> T.next(map : (T) -> R) : R = map(this) |