Why does Colors.cs use a Dictionary for storing the colors? #5202
c-schembri
started this conversation in
Scripting
Replies: 1 comment 1 reply
-
I don't know much about C# in Godot, but the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm talking about the
Colors.cs
file found atmodules/mono/glue/GodotSharp/GodotSharp/Core/Colors.cs
.This file has a
Dictionary<string, Color>
which stores a list of colors. Accessing any of these colors is then done like so:public static Color AliceBlue { get { return namedColors["ALICEBLUE"]; } }
Why is the implementation not just done like the following?
public static readonly Color AliceBlue = new Color(0.94f, 0.97f, 1.00f);
What's the need for the dictionary when we have a getter for every dictionary entry anyway?
Beta Was this translation helpful? Give feedback.
All reactions