I think I'm right in thinking that this is correct behaviour according to the documentation. Velocity never assigns null - there isn't a mechanism for assigning null to a variable in VTL. However, if the result of a computation or set statement would be null, then the assignment is ignored.
So, the correct way of achieving what you want is this; #foreach ($student in students) #if ($storedTimes.get($student.getID())) #set($storedMap = $storedTimes.get($student.getID())) $student.getID() $storedMap <br> #end #end As an aside, I've stumbled over this behaviour before and would like it if it can be changed so that you can assign null to a variable - what are the thoughts of others (and the code contributors)? Steve -----Original Message----- From: [EMAIL PROTECTED] .org [mailto:[EMAIL PROTECTED] a.apache.org] On Behalf Of Daniel Brownell Sent: 29 September 2005 23:49 To: Velocity Users List Subject: Map.get(missingKey) doesnt return null. Hi there, Thanks for the help on the Map of maps question. This question is related. Velocity is giving me values when I should be getting null. Here is the code: #foreach ($student in students) #set($storedMap = $storedTimes.get($student.getID())) $student.getID() $storedMap <br> #end In the output below, 6 of the students are'nt actually mapped in $storedMap. Only the first of the students with sh=10, sh=1 or sh=6 are actually in my HashMap. (ie. 492,493,496,497 are using 491's value.) For some reason, the value of $storedMap is not updated to be null, as it should, and I get stragglers copying values that aren't theirs. My check for null is useless because Velocity is not behaving. 581502 {sh=7, eh=7, sa=PM, ea=PM, sm=30, em=00} 581503 {sh=8, eh=7, sa=PM, ea=PM, sm=30, em=00} 581504 {sh=9, eh=7, sa=PM, ea=PM, sm=30, em=00} 581491 {sh=10, eh=7, sa=PM, ea=PM, sm=30, em=00} 581492 {sh=10, eh=7, sa=PM, ea=PM, sm=30, em=00} 581493 {sh=10, eh=7, sa=PM, ea=PM, sm=30, em=00} 581496 {sh=10, eh=7, sa=PM, ea=PM, sm=30, em=00} 581497 {sh=10, eh=7, sa=PM, ea=PM, sm=30, em=00} 581505 {sh=1, eh=6, sa=AM, ea=PM, sm=30, em=15} 581506 {sh=1, eh=6, sa=AM, ea=PM, sm=30, em=15} 581507 {sh=6, eh=6, sa=AM, ea=PM, sm=30, em=30} 581508 {sh=6, eh=6, sa=AM, ea=PM, sm=30, em=30} 581495 {sh=6, eh=6, sa=AM, ea=PM, sm=30, em=30} Thanks Dan --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]