The compiler does not recognize a nullable can be inspected with HasValue
private void SomeFunc(int? nullableInt)
{
if (!nullableInt.HasValue) return;
…
}
The compiler does not recognize a nullable can be inspected with HasValue
private void SomeFunc(int? nullableInt)
{
if (!nullableInt.HasValue) return;
…
}
Nullable are proper nullable on Elementals, you will want to check for != null
, and you can access their value directly if they aren’t null.
Hi!
Thanks for the quick answer, I applied that change already, but wanted to know if this was a design on Elementals or a bug.
The context is we have a c# project that generates a library that we use on a game in Unity. I need to run that same library on our backend in Java, so I’m on the process of evaluate solutions and found your product.
It would be nice to have a list of differences between regular C# and Elementals implementation, so it is not a surprise. According to this page:https://docs.elementscompiler.com/Hydrogene/CSharpEvolution/ you support 7.1 but so far I found this is different and also how event
is treated as List.
I Would appreciate if you have a consolidated diff.
Thanks!
/Simon
I believe this is the only major/relevant difference (aside from additive extensions). The background is that in or C# nullables work as they have in our other languages, before we added C#, in that ideally you should see no different using a nullable value type and a (nullable by default) reference, and how you interact with them. See Nullability.
I’ll make a point to cover this difference in Language Extensions
I need to update the Evolution age to match the latest. We support quite a few 8.x features as well, but I’m not fully caught up with exact status; I’ll get that updated.
Can you elaborate on this? I’m not aware of an (intentional) difference with how .NET events work in our C# vs VC#, so this might be a bug.
Hi!
On regular .NET you can do:
public event ChangeDelegate OnChange;
private void SomeFunction()
{
OnChange?.Invoke();
}
This will not compile on Fire because OnChange gets interpreted as a List. So only way to make it work is to do a foreach loop or use a lambda expression.
No member "Invoke" on type "java.util.ArrayList<ChangeDelegate>"
I’m using RTL.
Thanks!
/Simon
Oh, on Java. That makes sense
I believe “.Invoke” is an implementation station detail for how events are handled on the . NET platform, as that is not the standard way to invoke them, as far as I recall — you would just call OnChange()
, no?
We try to duplicate features — such as events — across platforms as we can, but the internal implementation details may vary. I would not consider 'Invoke` part of the C# *language spec of how events work. On .NET it will work, even from RemObjects C#, as it;'s a platform detail.
Does that make sense?
Thanks for the clarification. That makes sense.