你是不是也这样?看着琳琅满目的海南特产,什么文昌鸡、和乐蟹、海南粉……名字听着都馋,可真拿到手,却有点懵:这到底该怎么吃啊?别慌,今天这篇就是专门写给新手小白、入门不懂的朋友看的“海南特产吃法大全”。咱们不整那些虚的,就聊最实在的吃法,保证你看完就能上手,从“两眼一抹黑”到“吃得明明白白”。对了,就像很多新手想了解“新手如何快速涨粉”一样,咱们今天的目标是“新手如何快速入门海南美食”。
先整明白:海南特产到底有哪些“狠角色”?
在开吃之前,咱得先认认门。海南特产大体上可以分成几大类:禽肉类名菜、海鲜水产、特色粉类小吃,还有那些让人眼花缭乱的热带水果与干货。 别被“名菜”、“特产”这些词吓到,其实它们就是海南人餐桌上最日常、最美味的代表。
*禽肉“四大天王”:这四位可以说是海南美食的门面担当。头一位就是文昌鸡,海南有“无鸡不成宴”的说法,过年过节它更是寓意大吉大利的C位主角。然后是加积鸭、东山羊和临高乳猪,个个都身怀绝技。
*海鲜“实力派”:靠海吃海,和乐蟹是其中的佼佼者,尤其是那金黄油亮的蟹膏,看着就让人流口水。各种海产干货,像鱿鱼干、虾米,也是浓缩了大海精华的美味。
*嗦粉的快乐:海南粉(包括抱罗粉)是很多海南人一天的开始,堪称“国民早餐”。它的妙处在于,一碗粉能变换出汤粉、腌粉(干拌)等多种吃法。
*甜蜜的负担:椰子制品(椰汁、椰肉零食)、热带水果(芒果、菠萝蜜等及其果干),以及清补凉这类糖水# [Kotlin] ???
?????
- ???(Generic)? ??? ???? ??? ???? ??? ????? ??? ? ???? ????.
- ???? ???? ??? ???? ???? ? ???? ??? ?? ???? ???? ??? ? ??? ????? ????.
- ???? `<>` ??? ???? ????.
```kotlin
class Box(t: T) {
var name = t
}
fun main() {
val box1: Box = Box(1)
val box2 = Box("Kotlin" ?? ?? ??
}
```
???? ??
- ???? `?? ???(type safety)`? ????.
- ???? `?? ??`? `? ??`? ??? ? ???? ??? ?????.
- ???? `?? ????(type parameter)`? ???? ???? ??? ??? ? ????.
- ???? `?? ??(type argument)`? ???? ???? ??? ??? ? ????.
- ???? `?? ????(type projection)`? ???? ??? ??? ????? ???? ??? ? ??.
???? ??
?????? ??
```kotlin
class MyClass(val data: T) {
fun getData(): T {
return data
}
}
```
????? ??
```kotlin
fun myFunction(data: T): T {
return data
}
```
???????? ??
```kotlin
interface MyInterface {
fun myFunction(data: T): T
}
```
???? ??
- ???? `?? ????`? `?? ??(type bound)`? ? ? ??.
- `?? ??`? `?? ????`? ?? ??? ?? ????? ??? ?? ????.
```kotlin
class Box(t: T) {
var name = t
}
```
- ?? ???? `Box` ???? `?? ????` `T`? `Number` ???? ?? ????? ??.
???? ???
- ???? ???(variance)? `?? ????`? ?? ?? ?? ??? ?? ??? ?? ??? ???? ????.
- ???? `???(covariance)`, `????(contravariance)`, `????(invariance)`?? ???.
???(covariance)
- `???`? `?? ????`? ?? ?? ?? ??? ?? ?? ?? ??? ?? ?? ????.
- `???`? `out` ???? ???? ????.
```kotlin
class Box(val value: T)
fun main() {
val box: Box = Box(1) // OK
}
```
????(contravariance)
- `????`? `?? ????`? ?? ?? ?? ??? ?? ??? ?? ??? ?? ?? ????.
- `????`? `in` ???? ???? ????.
```kotlin
class Box(var value: T)
fun main() {
val box: Box = Box(1) // OK
}
```
????(invariance)
- `????`? `?? ????`? ?? ?? ?? ??? ?? ??? ?? ??? ?? ?? ?? ????.
- `????`? `?? ????`? `in`?? `out` ???? ???? ??? ????? `????`??.
```kotlin
class Box(var value: T)
fun main() {
val box: Box = Box(1) // Error
}
```
???? ?? ????
- `?? ????(type projection)`? ??? ??? ????? ???? ???? ?? ????.
- `?? ????`? `in`? `out` ???? ???? ????.
```kotlin
fun copy(from: Array, to: Array) {
// ...
}
```
- ?? ???? `from` ????? `Array` ???? ???? ??.
- ?? `from` ????? ???? ??? ??? ??? ? ? ??, ??? ? ? ??? ?? ????.
???? ?? ??
- `?? ??(type erasure)`? ??? ?? ??? ???? ???? ?? ????.
- `?? ??`? ??? ??? ????? ??? ? `?? ??` ??? ???? ??? ????.
```kotlin
fun main() {
val list1: List = listOf("a" ""c" val list2: List = listOf(1, 2, 3)
println(list1::class) // class java.util.ArrayList
println(list2::class) // class java.util.ArrayList
}
```
- ?? ???? `list1`? `list2`? ?? `ArrayList` ???? ??????.
- ?? `?? ??`? ?? `List`? `List`? ?? ??? ???? ???? ????.
???? reified ?? ????
- `reified` ?? ????? `?? ??`? ?? ???? ?? ??? ???? ???? ?? ????.
- `reified` ?? ????? `inline` ????? ??? ? ??.
```kotlin
inline fun isA(value: Any) = value is T
fun main() {
println(isA(" // true
println(isA(123)) // false
}
```
- ?? ???? `isA` ??? `reified` ?? ???? `T`? ???? ??.
- ?? `isA` ??? ??? ? `T`? ?? ??? ???? ??? ? ?? ???.
???? ?? ????
- `?? ????(star projection)`? `?? ??`? ? ? ?? ??? ??? ???? ?? ????.
- `?? ????`? `*` ??? ???? ????.
```kotlin
fun printList(list: List<*>) {
for (item in list) {
println(item)
}
}
```
- ?? ???? `printList` ??? `List<*>` ??? ????? ???.
- ?? `printList` ??? `List`? ??? ??? ? ? ??, ??? ? ? ??? ?? ????.
???? where ?
`where` ?? `?? ????`? ?? ?? `?? ??`? ?? ?? ????.```kotlin
fun copyWhenGreater(list: List, threshold: T): List
where T : CharSequence,
T : Comparable {
return list.filter { it > threshold }.map { it.toString() }
}
```
- ?? ???? `copyWhenGreater` ??? `?? ????` `T`? `CharSequence`? `Comparable` ?????? ?? ???? ??.
??
- ???? ??? ???? ??? ???? ??? ????? ??? ? ???? ????.
- ???? ???? ??? ???? ???? ? ???? ??? ?? ???? ???? ??? ? ??? ????? ????.
- ???? `?? ???(type safety)`? ????.
- ???? `?? ??`? `? ??`? ??? ? ???? ??? ?????.
- ???? `?? ????(type parameter)`? ???? ???? ??? ??? ? ????.
- ???? `?? ??(type argument)`? ???? ???? ??? ??? ? ????.
- ???? `?? ????(type projection)`? ???? ??? ??? ????? ???? ??? ? ??.
- ???? `?? ??(type erasure)`? ?? ???? ?? ??? ????.
- `reified` ?? ????? `?? ??`? ?? ???? ?? ??? ???? ???? ?? ????.
- `?? ????(star projection)`? `?? ??`? ? ? ?? ??? ??? ???? ?? ????.
- `where` ?? `?? ????`? ?? ?? `?? ??`? ?? ?? ????.
??
- [Kotlin Generics](https://kotlinlang.org/docs/generics.html)
- [Kotlin Generics: in, out, where](https://kotlinlang.org/docs/generics.html#variance)
- [Kotlin Generics: type projections](https://kotlinlang.org/docs/generics.html#type-projections)
- [Kotlin Generics: star projections](https://kotlinlang.org/docs/generics.html#star-projections)
- [Kotlin Generics: reified type parameters](https://kotlinlang.org/docs/inline-functions.html#reified-type-parameters)
- [Kotlin Generics: where clause](https://kotlinlang.org/docs/generics.html#where-clauses)