Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[help] dose naalaa has null type or a way to check if null?
#1
Question 
the title and also is there a way to check if an object attribute exists?

let's say in an object array something like:

o?[2]

if not o[1].x then return 0

that code should stop a function if o[1].x doesn't exist.

in java/cpp it will be:

if(o != null){}

in php:

if(isset(o)){}

if naalaa don't have this implemented it will be hard to find a way around it.

dose naalaa has try catch maybe?

 as always thank you for your help.
Reply
#2
(01-26-2019, 08:27 PM)rolen Wrote: the title and also is there a way to check if an object attribute exists?

let's say in an object array something like:

o?[2]

if not o[1].x then return 0

that code should stop a function if o[1].x doesn't exist.

in java/cpp it will be:

if(o != null){}

in php:

if(isset(o)){}

if naalaa don't have this implemented it will be hard to find a way around it.

dose naalaa has try catch maybe?

 as always thank you for your help.

I'll see if I can add something to check if an object field exists, hopefully this weekend.
Reply
#3
(01-26-2019, 08:27 PM)rolen Wrote: the title and also is there a way to check if an object attribute exists?

let's say in an object array something like:

o?[2]

if not o[1].x then return 0

that code should stop a function if o[1].x doesn't exist.

in java/cpp it will be:

if(o != null){}

in php:

if(isset(o)){}

if naalaa don't have this implemented it will be hard to find a way around it.

dose naalaa has try catch maybe?

 as always thank you for your help.

I'll see if I can add something to check if an object field exists, hopefully this weekend.
Reply
#4
that would be very helpful when creating dynamic object arrays. as of now, I have to specify the array size and init all of the objects before I can loop and check/manipulate the existing object atts (or else it will return an error like "object member does not exist").

for deleting I simply reinit the array (with smaller size) and copy the elements minus the deleted one from a temp array(containing the original data).

I tried this and it works.

for inspiration check the isset function in php its the best and easiest way to check if anything is not null. java, cpp,pythot etc doesn't have that useful func.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)