• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL, HF page 379

 
Judy Collins
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure enough why do these two expressions yield same result?

${person.dog.toys[0].name} and
${person.dog.toys["0"].name},
[ November 22, 2004: Message edited by: Judy Collins ]
 
Sudhakar Guntaka
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Judy,
Those two expression will get the same result because
1.In the first expression, array index is an integer value i.e 0. So it will get the first value present in the array.
2.In the second expression, array index is a string literal i.e "0". So that will be converted in to an integer value i.e 0. At this stage this expression will be equal to first expression and produce the same result.
3.String literals in array or list index will be converted to their corresponding numeric(integer) values.
4.Just go through page no.372 as it was very clear in that page.

cheers,
Sudhakar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic