crystal lang can you import static a method?

Yes, using keyword args (kwargs):

 

class Y
def self.method(c)
puts “got #{c}”
end
end

class Z
def imported(*args, **kwargs)
Y.method(*args, **kwargs)
end
end

Z.new.imported “here ya go” # or could do a local method “def imported…”

 

inspired by ref

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.