Alexander Stolte Expert Licensed User Longtime User Dec 3, 2020 #1 hey, can this be simplified somehow? B4X: Copy If tmp_m.Get("type") = 1 Or tmp_m.Get("type") = 2 Or tmp_m.Get("type") = 3 Or tmp_m.Get("type") = 4 Or tmp_m.Get("type") = 5 Or tmp_m.Get("type") = 6 Or tmp_m.Get("type") = 7 Or tmp_m.Get("type") = 8 Then Log("test") End If
hey, can this be simplified somehow? B4X: Copy If tmp_m.Get("type") = 1 Or tmp_m.Get("type") = 2 Or tmp_m.Get("type") = 3 Or tmp_m.Get("type") = 4 Or tmp_m.Get("type") = 5 Or tmp_m.Get("type") = 6 Or tmp_m.Get("type") = 7 Or tmp_m.Get("type") = 8 Then Log("test") End If
angel_ Well-Known Member Licensed User Longtime User Dec 3, 2020 #2 B4X: Copy If 9 > tmp_m.Get("type") Then Log("test") End If Upvote 0
M MikeSW17 Active Member Licensed User Longtime User Dec 3, 2020 #3 Why Not: Code: Copy If tmp_m.Get("type") > 0 and tmp_m.Get("type") < 9 Then Log("test") End If Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Dec 3, 2020 #4 I wouldn't call Map.Get multiple times like this. Not for performance reasons, but to make it easier to change the key in the future. Code: Copy Dim i As Int = tmp_m.Get("type") If i >= 1 And i <= 9 Then Upvote 0
I wouldn't call Map.Get multiple times like this. Not for performance reasons, but to make it easier to change the key in the future. Code: Copy Dim i As Int = tmp_m.Get("type") If i >= 1 And i <= 9 Then
Alexander Stolte Expert Licensed User Longtime User Dec 3, 2020 #5 Is this possible?: B4X: Copy If in array(1,2,3,6,7,8,20) = tmp_m.Get("type") then Upvote 0
angel_ Well-Known Member Licensed User Longtime User Dec 3, 2020 #6 Maybe this: B4X: Copy Dim tipo As String = tmp_m.Get("type") Dim Lista As List = Array As String(1, 2, 3, 6, 7, 8, 20) Log(Lista.IndexOf("" & tipo) > -1) Upvote 0
Maybe this: B4X: Copy Dim tipo As String = tmp_m.Get("type") Dim Lista As List = Array As String(1, 2, 3, 6, 7, 8, 20) Log(Lista.IndexOf("" & tipo) > -1)
Sandman Expert Licensed User Longtime User Dec 3, 2020 #7 In theory it might be possible to do something like this. Doesn't work though, IndexOf isn't supported by arrays. Perhaps there's an alternative way of writing this that works? Code: Copy If (Array As String(1, 2, 3, 6, 7, 8, 20)).IndexOf(tmp_m.Get("type")) > -1 Then ' Code goes here End If Upvote 0
In theory it might be possible to do something like this. Doesn't work though, IndexOf isn't supported by arrays. Perhaps there's an alternative way of writing this that works? Code: Copy If (Array As String(1, 2, 3, 6, 7, 8, 20)).IndexOf(tmp_m.Get("type")) > -1 Then ' Code goes here End If
Erel B4X founder Staff member Licensed User Longtime User Dec 3, 2020 #8 Code: Copy Sub InArray(Item As Object, Arr As List) As Boolean Return Arr.IndexOf(Item) <> -1 End Sub If InArray(7, Array(1, 2, 3, 4, 5, 6)) Then Upvote 0
Code: Copy Sub InArray(Item As Object, Arr As List) As Boolean Return Arr.IndexOf(Item) <> -1 End Sub If InArray(7, Array(1, 2, 3, 4, 5, 6)) Then
M Mahares Expert Licensed User Longtime User Dec 3, 2020 #9 Here is my 2 cents worth in my suitCASE or briefCASE: Code: Copy Select 5 Case 1, 2, 3, 4, 5, 6 Log("I am here") Case Else Log("I don't exist") End Select Upvote 0
Here is my 2 cents worth in my suitCASE or briefCASE: Code: Copy Select 5 Case 1, 2, 3, 4, 5, 6 Log("I am here") Case Else Log("I don't exist") End Select
Sandman Expert Licensed User Longtime User Dec 3, 2020 #10 Mahares said: Here is my 2 cents worth in my suitCASE or briefCASE Click to expand... I would hope the compiler adjusted your code to: Code: Copy Log("I am here") Upvote 0
Mahares said: Here is my 2 cents worth in my suitCASE or briefCASE Click to expand... I would hope the compiler adjusted your code to: Code: Copy Log("I am here")