You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val df1 = dataFrameOf("name", "age")(
"Alice", 15,
"Bob", 20,
"Charlie", 100
)
val name by column<String>()
val name_age by column<String>()
df1.add(name_age) { name +"!!!" }.also { println(it) }
df1.add(name_age) { "!!!"+ name }.also { println(it) }
The first println (name + "!!!") produces:
name age name_age
0 Alice 15 Alice!!!
1 Bob 20 Bob!!!
2 Charlie 100 Charlie!!!
The second println ( "!!!" + name) produces:
name age name_age
0 Alice 15 !!!org.jetbrains.kotlinx.dataframe.im...
1 Bob 20 !!!org.jetbrains.kotlinx.dataframe.im...
2 Charlie 100 !!!org.jetbrains.kotlinx.dataframe.im...
The root cause is that In the two example + resolves to different functions. A foot gun that should be fixed.
The text was updated successfully, but these errors were encountered:
It should indeed be fixed but unfortunately we can't. It's a language limitation.
Have you tried making a function like operator fun String.plus(something)?
Since String already has a function plus, an extension function overload will never be called by default.
Might indeed be a good idea to add ColumReference<String>.append() and .prepend() or something similar and through deprecations steer users to those :)
We still cannot prevent "" + anything from becoming a String though
Jolanrensen
changed the title
tyepe of a cell value in a new column depends on the order of calculation"" + columnRef becomes StringJun 25, 2024
Sample code (version 0.12.0):
The first println (
name + "!!!"
) produces:The second println (
"!!!" + name
) produces:The root cause is that In the two example
+
resolves to different functions. A foot gun that should be fixed.The text was updated successfully, but these errors were encountered: