Let block not working, giving "Only safe (?.)…" error

My parent variable is nullable, and haves a getWidth function. I wanna call getWidth only if parent is not null, so i did this let function. return parent.let { it.getWidth() * (perWidth / 100.0f) } ?: run{ App.realWidth.toFloat() } Also, if is null, I wanna call App.realWidth.toFloat(), so I added it in a ?: run… Read More Let block not working, giving "Only safe (?.)…" error

How to apply function that returns Result to each element of HashSet in Rust

As a language that aims for safety and performance, Rust provides a powerful data structure called HashSet that provides a fast and efficient way to store and retrieve unique values. HashSet is optimized for scenarios where you need to check for the presence of a value and avoid duplicates, making it a popular choice among… Read More How to apply function that returns Result to each element of HashSet in Rust

What happens when using 'this' inside a lambda expression that is sent to let function?

I’ve looked at the source code of let function: @kotlin.internal.InlineOnly public inline fun <T, R> T.let(block: (T) -> R): R { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block(this) } i clearly understand that using it keyword inside of the block (code) i’m sending to let function will refer to the object that called the let… Read More What happens when using 'this' inside a lambda expression that is sent to let function?