[Qt-qml] Semantics of 'return' in a JavaScript block in QML

Pertti Kellomäki pertti.kellomaki at nokia.com
Wed Sep 15 14:15:26 CEST 2010


This caught my eye when looking at examples in the qt-components project 
[1]. It looks like 'return' can be used to return a value from a script 
block:

Text {
    text: { if (condition) {
                  return "A";
               }
               return "B";
             }
}

My JavaScript knowledge is pretty much nonexistent, but cursory googling 
would suggest that 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?

[1] <http://qt.gitorious.org/qt-components/qt-components>
-- 
Pertti




More information about the Qt-qml mailing list