amanda.hinchman-dominguez
01/10/2019, 7:27 PMforEach
but -amanda.hinchman-dominguez
01/10/2019, 7:27 PMamanda.hinchman-dominguez
01/10/2019, 7:28 PMkarelpeeters
01/10/2019, 7:29 PMsbeve
12/10/2020, 9:37 AMuser
12/10/2020, 10:09 AMuser
12/10/2020, 1:43 PMuser
12/10/2020, 1:49 PMuser
12/10/2020, 3:37 PMcrummy
12/10/2020, 7:16 PMkenkyee
12/10/2020, 7:45 PMuser
12/11/2020, 8:02 AMuser
12/11/2020, 10:23 AMuser
12/11/2020, 3:20 PMalilosoft
12/13/2020, 8:39 PMkotlin.Result
can't be used as return type for functions, unless used with the compiler flag -Xallow-result-return-type
.
So fun parseInt(s: String) = runCatching { s.toInt() }
will not compile.
But what I find weird is that it can be used in function literals, as follow:
val parseInt:(String)->Result<Int> = {n-> runCatching{n.toInt()}}
or:
val parseInt: (String)->Result<Int> = fun(n) = runCatching{n.toInt()}
The last two will compile correctly without using the compiler flag!
Why and what's the difference? doesn't the same problem (i.e: future breaking changes) apply for both? or I'm missing something?Javier Vieira
12/14/2020, 9:04 AMPeter Ertl
12/14/2020, 10:51 AMuser
12/14/2020, 2:43 PMuser
12/14/2020, 6:24 PMuser
12/15/2020, 9:26 AMYoussef Shoaib [MOD]
12/15/2020, 6:13 PMEkaterina Volodko [JB]
12/16/2020, 9:28 AMuser
12/16/2020, 1:00 PMuser
12/16/2020, 3:41 PMuser
12/17/2020, 8:18 AMuser
12/17/2020, 3:25 PM