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
data class Wrapper(val id: String) | |
val ids = listOf("id1", "id2") | |
listOf( | |
Wrapper("id1").id, | |
Wrapper("id2") | |
).forEach { someId -> // inferred as Any | |
val result = ids.find { it == someId } | |
// id2 will never be found, but the compiler won't tell you | |
} |
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
""" | |
Use-case: automate clones in Databricks for dev testing similar to Snowflake's zero-copy clone. | |
This doesn't use the Catalog API as that may rely on cred passthrough | |
- https://docs.microsoft.com/en-us/azure/databricks/security/credential-passthrough/adls-passthrough | |
`py4j.security.Py4JSecurityException: method ... is not whitelisted on class org.apache.spark.sql.catalog.Table` | |
""" | |
prefixes = ["layer_a", "layer_b"] # prefix matching on schemas to copy over for layers |
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
enum E { | |
A = "A", | |
B = "B", | |
} | |
const yep: "A" = E.A; | |
const yep2: E = E.A; | |
const nope: E = "A"; // why though |
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
interface Service { | |
update(obj: { id?: string }): void; | |
// changing this to a function type `update: (obj: {id?: string}) => void` works | |
// and causes the implementation not to type-check | |
} | |
class ServiceImpl implements Service { | |
// somehow this is a valid implementation | |
update(obj: { id: string }): void { | |
// `id` can never be undefined or null here according to the type system |
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
// scala version | |
def mostFrequent(arr: Array[Int]): Int = { | |
arr.groupBy(identity).maxBy(_._2.size)._1 | |
} | |
// java version (from https://www.geeksforgeeks.org/frequent-element-array/) | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Map.Entry; | |