Closed yjhmelody closed 3 years ago
Could you try:
expect(b3 == b4).toStrictEqual(true);
expect(b3 != b4).toStrictEqual(false);
Does it change something?
Could you try:
expect(b3 == b4).toStrictEqual(true); expect(b3 != b4).toStrictEqual(false);
Does it change something?
Yes, I meet compiling errors.
ERROR TS2322: Type 'bool' is not assignable to type 'assembly/box/Box<bool>'.
expect(b3 == b4).toStrictEqual(true);
~~~~
in assembly/__tests__/box.spec.ts(120,40)
ERROR TS2322: Type 'bool' is not assignable to type 'assembly/box/Box<bool>'.
expect(b3 != b4).toStrictEqual(false);
~~~~~
in assembly/__tests__/box.spec.ts(121,40)
The True/False are Box version of true/false.
I try to write a minimal example to reproduce it but I failed. I don't know why.
BTW, the static method from
in Box2 return Box rather than Box2.
Hmm, but why you return eq:: Box -> Box -> Box
intead eq:: Box -> Box-> bool
?
Hmm, but why you return
eq:: Box -> Box -> Box
inteadeq:: Box -> Box-> bool
?
Because primitve cannot be null, So I always return box version. But this kind of design shouldn't cause this kind of logical problem.
Rust for example always return bool for Ord/PartialOrd
Rust for example always return bool for Ord/PartialOrd
Well, when I change the APIs to rust style, the problem disappeared. But still need to know why there is such a problem.
Rust for example always return bool for Ord/PartialOrd
I think the API means to deref box internally, so it return bool. But in as
if we want to operate in generic class, I think always keep it Box version is fine and more consistent.
And my box is for primitve type which cannot be null, is not a rust semantic box.
Basically Box container makes sense only for Rust-like languages which alloc all variables on stack by default. TS/Kotlin/Swift/Haskell hasn't this container in stdlib
Basically Box container makes sense only for Rust-like languages which alloc all variables on stack by default. In TS/Kotlin/Swift/Haskell hasn't this container in stdlib
yeah, I see. It's used to wrap primitive type just like Java boxing type.
Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes.
as
Cannot autoboxing, so I defined this type.
Rust for example always return bool for Ord/PartialOrd
I have thought about it these days, and it is indeed better to return a Boolean value than its Box version. Anyway, thank you for your suggestion
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions!
See my repo https://github.com/yjhmelody/as-container/blob/overload-for-subclass/assembly/__tests__/box.spec.ts#L112
The test is always passed.
How to test