New topic: the NEW keyword
<http://forums.realsoftware.com/viewtopic.php?t=32261> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message Intelligent007 Post subject: the NEW keywordPosted: Sat Jan 30, 2010 6:01 am Joined: Tue Jul 28, 2009 1:08 am Posts: 10 Hello, I'm studying a bit on RB programming, and I read that sometimes you have to use the "New" keyword, like for example the code: dteMyAnniversary = New Date Can anyone help me explaining why I have to use this "New" keyword? Thank you; birgit Top jefftullin Post subject: Re: the NEW keywordPosted: Sat Jan 30, 2010 6:09 am Joined: Wed Nov 15, 2006 3:50 pm Posts: 1261 Imagine that you know that things called Cars exist. You know about them: how they need gas, how you can start them and so on. But you wont be able to actually do it unless you have one. So you get a new car. Now it needs space on your drive, it needs gas, and you can crash it if you handle it the wrong way. Want more for your friends? Buy more new cars. Some things dont need to be Newed. Integers and doubles, for instance are basic types, they occupy a known space, and Dim x as integer does all that is required. The memory it occupies is set to the value of 0 for you. But something more complex, such as a 'piggy bank' object, can carry extra functionality: methods and properties. The New operation can call the contructor method of this class, which allows the author to perform some initial setting up before you get your hands on it. Back to the car analogy, asking for a New car allows the dealer to put some gas in and paint it the right color before you get it. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
