Re: Hashes (in general)
Brian Pontarelli <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
> > With the proper wrapper you can access the Java Map facility (i.e., > you can use non-string keys; see Attila's answer), but the FTL hash > type is defined as something that associates *strings* with arbitrary > values. So it's not the same as Java's Map-s. For that reason > myMap[key] will always expect a string in FTL. Anyway, I think that a > template language should rather have something like Java's Map-s than > something like FTL's hashes... but in 2.4 the hash type still only > allow string keys. I agree. The template language capable of handling all the cases for non-string keys, include complex object keys. Seem simple to me. The whole wrapping process is somewhat interesting to me in general. Not sure if I like it or not yet. > >> - Is there a way currently to get FM to stop wrapping the Map with an >> incorrect version that has String keys and null values? > > Does such thing happen? Maybe it's just that for missing items the > Hash API (also the Java Map API) returns Null. So, myMap["1"] is null, > because indeed there is no item with key "1" (only with key 1). Yeah. It doesn't unwrap the map directly. It creates a special Map that is an adapter with a custom entry set. It definitely can make things messy. -bp ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ FreeMarker-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-user