Could at least save a line via return unless tex = @tex. Is there a world in which @tex just isn’t nilable so you could avoid doing a nil check at all?
Since @tex is inferred to be the nilable Pointer | Nil type in your program, you must assign it to a local variable to reduce its type to Pointer:
if tex = @tex
LibSDL.set_texture_alpha_mod(tex, 255)
end
You might also want to understand why @tex is inferred (or declared) as a nilable, and try to avoid it. That would use less memory, and you could use @tex directly (or still do an if check to rule out NULL pointers).