Function definition expressions containing blocks currently aren't working.
![Embarrassed :oops:](./images/smilies/icon_redface.gif)
I see, thanks. I realized after posting it that not just "switch" blocks, but "if" blocks also inside function definition expressions will throw.
Code: Select all
Array.Prototype.DefineProp("Find", {Call: (Arr, FindCondition){
if HasMethod(FindCondition)
{
for i, e in Arr
if FindCondition(e)
return i
return 0
}
else
{
for i, e in Arr
if e==FindCondition
return i
return 0
}
}})
MsgBox(([1,2,3]).Find(3)) ; 3
Code: Select all
Array.Prototype.DefineProp("Find", {Call: (Arr, FindCondition){
if HasMethod(FindCondition)
{
for i, e in Arr
if FindCondition(e)
return i
return 0
}
else
{
FindConditionFunc := (x) => x==FindCondition ; <<<<
for i, e in Arr
if FindConditionFunc(e) ; <<<<
return i
return 0
}
}})
MsgBox(([1,2,3]).Find(3))
Code: Select all
let v = 1
{
let v = 2
console.log(v)
}
console.log(v)
Code: Select all
i := 1
((i?){
i := 2
Msgbox(i)
})()
Msgbox(i)
Code: Select all
func(){
if (condition) {
v1 := 1
v2 := 2
; ...
}
; ....
}
Code: Select all
func(){
if (condition) {
(){
v1 := 1
v2 := 2
; ...
}()
}
; ....
}
It's truecumulonimbus wrote: ↑04 Sep 2023, 18:37There are a lot of people who object to this way of defining things, but there are also a lot of people who like it, and what you think is "symbolic hell" may be a paradise of simplicity in the eyes of others.
I wholeheartedly agree with this statement. As much as this feature irks me, I think each developer must write the code as they want.lexikos wrote: ↑10 Sep 2023, 02:50And you are missing the point. Imposing arbitrary restrictions will not force anyone to write readable code. Each author is free to write the code in whatever way he finds best, within the constraints of the language. I have no reason to take your opinion of what is readable as law. If an author wants to write unreadable code, he is free to do that as well, within the constraints of the language.