How to call a function on a variable?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaaaxiKing
extends Control

var color = "ffffff"

func _ready():

I want to print the color via calling print on color, so color.print(). (How) can I do this?

Not sure if I can follow…

Instead of doing print(color) you want to do color.print? Why?

If color would be a class and implement a method called print that would work. However, in your example color is a String, which doesn’t have such a method.

njamster | 2020-06-06 12:53