classic icon indicating copy to clipboard operation
classic copied to clipboard

Error free as method

Open Shadowblitz16 opened this issue 2 years ago • 4 comments

function Object:as(T)
	if self.is(T) then 
		return self
	end
	return T
end

Shadowblitz16 avatar Dec 19 '21 05:12 Shadowblitz16

@Shadowblitz16 what? More details please?

flamendless avatar Dec 19 '21 06:12 flamendless

Its a suggestion for a as method. basically its the same as is but it returns the object if its of that type instead of a bool. If not it either returns nil or a temporary value of that type so you don't get nil errors when accessing the data.

Shadowblitz16 avatar Dec 19 '21 18:12 Shadowblitz16

You can easily create your own method for that, i dont think this is needed in classic unless im mistaken.

flamendless avatar Dec 20 '21 00:12 flamendless

It would be easy to create unless you implement a work around for is and as or nil instances

Shadowblitz16 avatar Dec 20 '21 02:12 Shadowblitz16