Function expression with msg_float() doesn't work

estevancarlos's icon

Maybe there's a variety of things wrong with this but I'm trying to figure out why I can't use msg_float in a function expression. Does anyone understand why?

Does not work:

var mf = function msg_float(x) {
    switch(inlet) {
        case 1:
        post('stuff');
        break;
    }
}
mf(x);

I get the error, "No function msg_float"

Works fine:

function msg_float(x) {
    switch(inlet) {
        case 1:
        post('stuff');
        break;
    }
}
do.while's icon

Hi !

your "msg_float" is private to your newly created function body only . its not in "jsthis" scope .

do.while's icon

#EDIT
: deleted as i was referring to different case

u can use both functions

var mf  = function(x){
    post(x,"\n")
};

var msg_float = mf;

estevancarlos's icon

Thanks for that clarification.