dave08
04/26/2021, 11:20 AMand { get(SomeClass::someProp).isEqualTo(...) }
on a nullable type without isNotNull()
allows the and
, but has get()
undefined... I wonder if it makes sense to have an and
in this case in the first place...? What can one do with a nullable type?
Also, is there anything like a isNotNullAnd { ... }
or withNotNull { }
? I find myself doing expectThat(result).isNotNull().and { ... }
quite often...christophsturm
04/26/2021, 11:29 AMisNotNull().and { ... }
is pretty short and nice to readchristophsturm
04/26/2021, 11:31 AMdave08
04/26/2021, 11:53 AMand
is really not an and
but rather testing the not null result... it's not a side-effect like and
seems to point out.dave08
04/26/2021, 11:54 AMmaybe we should allow and only on not null receivers?That's what I was wondering... but maybe there's some use-case for that I'm not thinking of?
dave08
04/26/2021, 11:55 AMand should only be used in not null contexts
or something?dave08
04/26/2021, 11:59 AMwith
... couldn't withNotNull { }
be such a mapper, when the main assertion is the expected non-null result's contents?dave08
04/26/2021, 12:00 PMisNotNull()
then it being an assertion in itself might make more sense...robfletcher
04/26/2021, 4:59 PMwithNotNull
. I’ve never been super happy with the naming of and
. It reads well in some contexts but not in others.christophsturm
04/26/2021, 5:18 PMrobfletcher
04/26/2021, 5:23 PMdave08
04/26/2021, 5:31 PMdave08
04/26/2021, 5:34 PMrobfletcher
04/26/2021, 5:36 PMwithNotNull
as an alias for .isNotNull().and { }
is useful enough to be worth addingdave08
04/26/2021, 6:09 PMrobfletcher
04/26/2021, 6:09 PMisEqualTo
on a null valuedave08
04/26/2021, 6:10 PMrobfletcher
04/26/2021, 6:10 PMrobfletcher
04/26/2021, 6:11 PM.isNotNull() isEqualTo "foo"
is more correct than just isEqualTo "foo"
dave08
04/26/2021, 6:15 PMand
on nullables also make sense? Inside it, there's not even a get() to use to test on multiple mapped properties..., or am I missing a use case?robfletcher
04/26/2021, 6:16 PMand
on a nullable, but I wouldn’t like to prevent it only to find there’s a good reason for someone to want itdave08
04/26/2021, 6:23 PMrobfletcher
04/26/2021, 6:25 PMchristophsturm
04/27/2021, 10:50 AMdave08
04/27/2021, 10:53 AMisXXX
in an and
block, since those can be chained. The main use of an and
block for me is to check properties of a class using get()
.christophsturm
04/27/2021, 10:55 AMchristophsturm
04/27/2021, 10:56 AMdave08
04/27/2021, 10:58 AMwithNotNull { }
would avoid together with the first option you stated).dave08
04/27/2021, 10:59 AMchristophsturm
04/27/2021, 11:25 AMchristophsturm
04/27/2021, 11:40 AMchristophsturm
04/27/2021, 11:41 AMdave08
04/27/2021, 11:42 AMdave08
04/27/2021, 11:43 AMchristophsturm
04/27/2021, 11:50 AMdave08
04/27/2021, 11:50 AMget { }
in a nullable and { }
block...christophsturm
04/27/2021, 11:51 AMchristophsturm
04/27/2021, 11:52 AMchristophsturm
04/27/2021, 11:52 AMdave08
04/27/2021, 11:59 AMget(SomeClass?::someProperty)
syntax exists in Kotlin... and get { }
gives you an error in the IDE...christophsturm
04/27/2021, 12:13 PMget(A?::hashCode)
worksdave08
04/27/2021, 12:16 PMhashCode
does, but other properties don't ... that's funny!robfletcher
04/27/2021, 4:11 PMchristophsturm
04/27/2021, 5:03 PM