Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error free as method #20

Open
Shadowblitz16 opened this issue Dec 19, 2021 · 4 comments
Open

Error free as method #20

Shadowblitz16 opened this issue Dec 19, 2021 · 4 comments

Comments

@Shadowblitz16
Copy link

Shadowblitz16 commented Dec 19, 2021

function Object:as(T)
	if self.is(T) then 
		return self
	end
	return T
end
@flamendless
Copy link

@Shadowblitz16 what? More details please?

@Shadowblitz16
Copy link
Author

Shadowblitz16 commented Dec 19, 2021

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 Shadowblitz16 changed the title error free as method Error free as method Dec 19, 2021
@flamendless
Copy link

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

@Shadowblitz16
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants