Hi Pertti.
2010/9/15 Pertti Kellomäki <[email protected]> > Text { > text: { if (condition) { > return "A"; > } > return "B"; > } > } > > (...) in JavaScript, a return statement can only be used > inside functions. Is the above syntax an extension of JavaScript, and if > so, is it documented somewhere? > My understanding is that in QML script blocks are implicit functions, and the above should be simply a more concise version of: Text { function foobar() { if (condition) return "A"; return "B"; } text: foobar() } Note that there's also a third valid version: Text { text: { if (condition) "A" else "B" } } where the last evaluated statement is used as return value. This is specially useful for one-liners like the one below. Text { text: condition ? "A" : "B" } Cheers, Eduardo -- Eduardo M. Fleury OpenBossa - INdT http://eduardofleury.com/ http://www.openbossa.org/
_______________________________________________ Qt-qml mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-qml
