This is my code for livescript:
if (res = json.msg.match /^iSearchup\s(.*)$/i)? then
getReq("[url='http://urbanscraper.herokuapp.com/define/'][http://urbanscraper.herokuapp.com/define/[/url]" + encodeURIComponent(msg.splice(1, msg.length - 1).join(" ")) + ".json", function(res, passback)
if (res.word && res.definition){
@socket.send JSON.stringify {
type: \pmsg
nick: 'iPoddy:'
msg: json.from + ": " + res.word + " - " + res.definition
}
}
else {
@socket.send JSON.stringify {
type: \pmsg
nick: 'iPoddy:'
msg: json.from + ": Sorry, no results were returned."
}
}
That is my code. It gave me the error "dedent" but I fixed it and it still give me that error again. Help?
You have several errors in this code. It will give you an error of
UNEXPECTED DEDENT
because you are mixing spaces and tabs and LiveScript is a whitespace-strict programming language. So on, avoid the use of brackets while using LiveScript. Remember also that in a conditional structure, likeif
, you might usethen
after. This will not compile due to:else
keyword with bracketsthen
after expression to determine conditionfunction(res, passback)
And you have some little issues and not standardized practices:
=
instead of==|~=
for comparasionfunction(res, passback)
+
to concat, instead of++
&&
operator, instead ofand
This should work well: