Hide this comment

Hello,

Thanks a lot for your answer.

I modified my code and it looks better now without "val" !!!

Olivier

By on 2/18/2009 1:32 PM ()Reply
Hide this comment

I got around the same problem your having by using as and then. I forget the exact reason why you can't reference this in new. Check out my blog. I recently started my own gaming project with XNA in F#.

I posted code that works which is very similar to yours. Scroll down a bit on my blog and you will see the new constructor i use. I'd post it here but I'm having issues using this sites bbcode.

By on 2/17/2009 3:03 PM ()Reply
Hide this comment

My first piece of advice is to never use 'val' - always define an 'implicit'/'primary' constructor on your class.

In your code, since you must initialize let-bound variables, you could just initialize 'm_camera' to 'null' (or Unchecked.defaultof<Camera> if Camera is an F# type) in the let, and then re-assign in in the constructor body ('do' block) as you are.

You're right that you can't use 'this' before the 'do' starts, so you have to do the initialize-to-some-throwaway-value-(e.g. null)-and-then-re-assign.

Does that answer your question?

By on 2/17/2009 2:27 PM ()Reply
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper

Logging in...