Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFS..pg.420

 
Deepa Korecherla
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the HFS book..the 7th question....Is the "C" option true??
If its true ...will it take the fifth key's value ..??
I don't understand..pls reply..
 
melan hen
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I think it's true, that means foo has an entry which is String type, and the string value is "5",so it is OK.
 
Deepa Korecherla
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think its not true....but still can anyone tell...??
It will work if foo is of type List but not Map...can anyone reply??
 
Deepa Korecherla
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody reply..with some explanation??
 
Ranjit Jana
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree ${foo["5"]} and $foo.[5] should be equivalent in List . Assume Map have a key which is of type String "5" then it may make a difference. but surely this is a confusing question . Better Author tell what was in there head.
 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Option C of question 7 is correct. If 'foo' is a Map, then the argument to the map is some object (here the string "5") that acts as the key into the map.

However, this syntax will also work for lists because EL will convert the string "5" into the integer 5 at runtime to find the index into the list.

Here is a small code example that demonstrates these two use cases.


What do you think the result would be?

Cheers,
Bryan
[ February 22, 2005: Message edited by: Bryan Basham ]
 
Ranjit Jana
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bryan,

This makes things clear.

I take this opportunity to compliment you for bringing out "HF servlets and JSP". No doubt your sleepless nights for bringing this book out have saved huge volume of midnight oil(at least for me).

:-)

Regards,
Ranajit Jana
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic