Android Question [SOLVED] Redeclaration of variable as shortcut - is it Ok to use? (YES)

Gandalf

Member
Licensed User
Longtime User
For example I have a custom type variable named RuntimeConfig declared in Starter module. This custom type contains UserDetails map. To get a value from UserDetails in Main activity I should use the following:

B4X:
Starter.RuntimeConfig.UserDetails.Get("FieldName")

If a lot of such addressing happens, even in one string sometimes, the code becomes bulky and ugly. It is possible to declare UserDetails as shortcut:

B4X:
Dim ud as Map = Starter.RuntimeConfig.UserDetails
If ud.Get("FieldName") = "someText" Then ud.Put("FieldName", TextField1.Text)

It works with all object variable types, but is it Ok to use?
 
Last edited:
Top