Void: When Functions Don't Return
When functions don't return anything to help us debug. Let's see how we can set our function to not return anything.
Video Transcript
00:00While you were gone, I created a simple function just to help us explain one more topic related to return types
00:07So all this function really does is it kind of like sends whatever information we send to it
00:12It just sends it. Oh, why am I always putting my name there? Hey
00:17There well because there's nothing else in my head, right?
00:20So if I run the application now all it's really going to do is send whatever I've sent to the say that to our trace
00:27So we're basically sending to our function and sending it onwards to our trace
00:31we're not returning anything and
00:34Because we're not really using the return type the way we could tell our function now before even say why?
00:41Before I say how we do it. Why would we want to tell flash that it doesn't return anything?
00:46The reason why we want to tell flash that it returns nothing is so if we by mistake return something it will give us a compiling
00:53error
00:54Okay now in more complex, you know environments
00:59It also helps, you know between the developers if more people are working in flex and people are working with more strict type
01:06mythologies of working
01:08They're gonna expect these parameters to be there and it doesn't hurt us to just add all we have to do instead of putting
01:14There are values such as numbers as we did before we could just set it as colon
01:19Void now in action script to void would be an uppercase
01:23But in action script to it's in lowercase and automatically flash notices that we've made that mistake and it makes it lowercase
01:31so though although in AS2 if you
01:34there's a good chance you never even used it, but a lot of developers did use the void and
01:39In AS2 you would set it up as an uppercase void in AS3 the big change is now it's lowercase
01:46Okay, so what this actually helps us do is if we try to return a value
01:52Let's say I'm going to try to return the value of 1 then flash is going to generate an error
01:56And it's going to tell me the value must be undefined
02:00But if I would just said as said it as return
02:03Then that's fine because we're not returning anything. We're just returning nothing
02:09now if you you might be asking me, so why would we return nothing and
02:13It links us into another topic going to throw them up all in together
02:18That the return the moment that return happens the application ceases to execute
02:25Okay, we're going to look a little bit deeper into that in the next video
