C
C#2y ago
androidui

explicit null param

is there a way to specify an explicit overload for null ? eg foo(object_a); // object overload foo(null); // null overload eg, equivilant to C++'s std::nullptr_t specifically to avoid
foo(C_A);
foo(C_B);
foo(null); // ambigous overload
foo(C_A);
foo(C_B);
foo(null); // ambigous overload
5 Replies
Thinker
Thinker2y ago
You can't have an overload specifically for null, although you can have an overload without the parameter entirely.
androidui
androidui2y ago
rip
Thinker
Thinker2y ago
Why would you want this anyway?
androidui
androidui2y ago
could i use IntPtr as an overload for null ? for this
public void SetChildValueNull (string name)
{
SkiaApi.sk_runtime_effect_builder_set_child_nullptr (Handle, name);
}

public void SetChildValue (string name, SKShader shader)
{
SkiaApi.sk_runtime_effect_builder_set_child_shader (Handle, name, shader.Handle);
}

public void SetChildValue (string name, SKColorFilter colorFilter)
{
SkiaApi.sk_runtime_effect_builder_set_child_color_filter (Handle, name, colorFilter.Handle);
}

public void SetChildValue (string name, SKBlender blender)
{
SkiaApi.sk_runtime_effect_builder_set_child_blender (Handle, name, blender.Handle);
}
public void SetChildValueNull (string name)
{
SkiaApi.sk_runtime_effect_builder_set_child_nullptr (Handle, name);
}

public void SetChildValue (string name, SKShader shader)
{
SkiaApi.sk_runtime_effect_builder_set_child_shader (Handle, name, shader.Handle);
}

public void SetChildValue (string name, SKColorFilter colorFilter)
{
SkiaApi.sk_runtime_effect_builder_set_child_color_filter (Handle, name, colorFilter.Handle);
}

public void SetChildValue (string name, SKBlender blender)
{
SkiaApi.sk_runtime_effect_builder_set_child_blender (Handle, name, blender.Handle);
}
Anton
Anton2y ago
Rename SetChildValueNull to SetChildValue, and just don't pass anything to it. If you need to check for null at runtime instead, then you'll need to do it in every function.
Want results from more Discord servers?
Add your server
More Posts