Or create a path.
A ray is not a line. A ray has a beginning and an end and is meant to report the first collision in between, plus some information about it, if any. But you can create a path of rays, a new ray at every collision point of the previous ray. But you need to specify exactly the conditions when to end the path. And doing this repeatedly may be slow in GDScript.
Without knowing what you want to achieve, which Godot version, 2D or 3D, what the scene is like, it is hard to answer more specific.