https://bugzilla.novell.com/show_bug.cgi?id=239005 Summary: Proper access of <any> value from maps and lists undocumented, including no docs for YCP function "is()" Product: openSUSE 10.2 Version: Final Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: P5 - None Component: YaST2 AssignedTo: yast2-maintainers@suse.de ReportedBy: odabrunz@novell.com QAContact: jsrain@novell.com There are many places where the is() function (e.g.: "is(WFM::Args(0), string)") is used, but I was unable to find the documentation. This function is needed whenever a value of type "any" is retrieved from a map or list, to use a proper default value. E.g., if the <any> values in my_map can contain <string>s or <integer>s: map<string,any> my_map = ...; sformat("%1", is(my_map[this]:nil, string) ? my_map[this]:"" : ( my_map[this]:nil == nil ? "" : my_map[this]:nil ) ); Most other approaches give error messages or unwanted behaviour as follows: my_map[this] = 123; sformat("%1", my_map[this]:"") -> Can't convert value '123' to type 'string' my_map[this] = "testing"; sformat("%1", my_map[this]:0) -> Can't convert value '"testing"' to type 'const integer' my_map[this] = nil; sformat("%1", my_map[this]:nil) -> no error, but output is 'nil' (and I want the empty string '') The only working alternative that does not need the "is()" function is this: sformat("%1", my_map[this]:nil == nil ? "" : my_map[this]:nil) I believe this is a standard situation and as such both alternatives should be documented. I could not find anything here: http://forgeftp.novell.com/yast/doc/SL10.2/tdg/Book-YaSTReference.html -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.