Matthew Good
04/29/2019, 4:29 PMval x: Stack<String> = "a"
auto convert to return Stack("a")
via some function without needing to explicitly state val x = Stack<String>("a")
Shawn
04/29/2019, 4:35 PMMatthew Good
04/29/2019, 4:36 PMShawn
04/29/2019, 4:36 PMShawn
04/29/2019, 4:36 PMval x = Stack("a")
is pretty concise, no?Shawn
04/29/2019, 4:37 PMT
anyhow)Matthew Good
04/29/2019, 4:40 PMfun makeStack(s: Stack): Stack = s
transform fun makeStack("a")
to makeStack(Stack("a"))
Matthew Good
04/29/2019, 4:42 PMMatthew Good
04/29/2019, 4:43 PMMatthew Good
04/29/2019, 4:45 PMMatthew Good
04/29/2019, 4:50 PMval A = IsSequenceOneOrMany("A")
val B = IsSequenceOneOrMany("B")
val AB = A and B
i can do this instead val AB: IsSequenceOneOrMany = "A" and "B"
Matthew Good
04/29/2019, 4:51 PMShawn
04/29/2019, 4:51 PMShawn
04/29/2019, 4:52 PMShawn
04/29/2019, 4:52 PMShawn
04/29/2019, 4:54 PMinfix fun String.and(other: String) = IsSequenceOneOrMany(this) and IsSequenceOneOrMany(other)
but that really probably shouldn’t be top-levelMatthew Good
04/29/2019, 4:55 PMShawn
04/29/2019, 4:56 PMMatthew Good
04/29/2019, 4:57 PMMatthew Good
04/29/2019, 4:59 PMX("string1" and "string2")
and val str = "string1" and "string2"
will each invoke different String.and
functions right?Matthew Good
04/29/2019, 5:01 PMscoping the code you add to a certain class
means that for example, function extentions for String will only be applied when given as a parameter for desired class or something similarShawn
04/29/2019, 5:01 PMShawn
04/29/2019, 5:02 PMval xInstance = buildX {
someField = "string1" and "string2"
}
Matthew Good
04/29/2019, 5:04 PMkarelpeeters
04/29/2019, 5:47 PMwbertan
04/29/2019, 5:56 PMdata class MyClass(val value: String)
val String.parse: MyClass
get() = MyClass(this)
@Test
fun asas() {
fun asas(myClass: MyClass): Unit = TODO()
asas("a".parse)
val x: MyClass = "a".parse
}