[Gambas-user] Methods on a property?

Fabien Bodard gambas.fr at ...626...
Mon Oct 31 10:46:32 CET 2016


2016-10-31 4:31 GMT+01:00 adamnt42 at ...626... <adamnt42 at ...626...>:
> Probably a dq, but..
> Is it possible to write a method, apart from _read and _write, on a property of a class? Specifically, I'd like to implement a boolean function to return true if the property has a specific value. Something along the lines of MyClass.MyDateProperty.IsFuture() which would return true if the current value of the property is a date in the future?
> There are obvious solutions along the lines of If MyClass.MyDateProperty>Date(Now()), I'm just trying to shortcut coding common checks in the client class.
>
> regards
> Bruce

I your case MyDateProperty is not a property but a class

Maybe if you create a new DateType that inneritate from Date and
adding some analysis feature.


--- MyDate Class---

inherit Date

Public sub IsFuture()
if super.value......
end


--Your Class--

Property Date as MyDate





So you can use like that

MyClass.Date = Date(...

If MyClass.Date.Future() then ...






> --
> B Bruen <adamnt42 at ...3379... (sort of)>
>
> ------------------------------------------------------------------------------
> The Command Line: Reinvented for Modern Developers
> Did the resurgence of CLI tooling catch you by surprise?
> Reconnect with the command line and become more productive.
> Learn the new .NET and ASP.NET CLI. Get your free copy!
> http://sdm.link/telerik
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



-- 
Fabien Bodard




More information about the User mailing list