Array Issue

Monkey Forums/Monkey Programming/Array Issue

ordigdug(Posted 2014) [#1]
PROBLEM SOLVED: Thanks Mark

Is this a bug or am I doing something wrong?

Import mojo

Class MyApp Extends App

	Field data:Int[5]

	Method OnCreate()
		SetUpdateRate 60
		
		Print data.Length	'5
		data.Resize(10)
		Print data.Length	'Why 5 and not 10?
	End
	
	Method OnUpdate()
		
	End
	
	Method OnRender()
		Cls		
	End

End

Function Main()
	New MyApp	
End



marksibly(Posted 2014) [#2]
data=data.Resize(10)


ordigdug(Posted 2014) [#3]
Thanks Mark


therevills(Posted 2014) [#4]
LOL! I was fighting this one over the weekend myself - took me a good half an hour before I slammed my head against the desk going "durrrrrrrrrrrrrrrrrr" ;)

BTW ordigdug, the code tags are [ code ] [/ code ] - without the spaces.
,


ordigdug(Posted 2014) [#5]
@therevills
Yeah I was at the brink of banging my head when I decided to post, I knew it was something simple. Thanks for the code tags I couldn't remember them and when I click "forum codes" nothing comes up but a blank window currently.


rIKmAN(Posted 2014) [#6]
With coding problems I always seem to have an epiphany around 2mins after I post on here, even if I have been fighting with it for an hour or two - makes me look really thick lol!


AdamRedwoods(Posted 2014) [#7]
http://en.wikipedia.org/wiki/Rubber_duck_debugging


dawlane(Posted 2014) [#8]
@therevills, ordigdug: That's nothing. I haven't use Monkey of a while and spent 45 minutes scratching my head wondering why the code below was loosing precision when doing a division.
Strict may catch some programming errors, but not all off them. I think you should be able to see why ;-)