Jump to content

Question Bool


WASSIm.

Recommended Posts

  • Moderators

you can do this:

local boolean = boolean == "true" and true or false 

Or you can make it a boolean(as you actually wanted to do it):

local boolean = loadstring("return " .. boolean)() 

But I prefer the first one, since it is faster with the same/better result.

It is better to get a boolean back then a nil, what ever happens in version 1 always returns a boolean.

Link to comment
  • Moderators

no, loadstring can still return a nil variable.

but: "or false" will change a nil to a false/boolean.

boolean = nil or false 
outputChatBox(type(boolean)) 

  
function toboolean(bool) 
    if (bool) then 
        return loadstring("return " ..bool)() or false 
    end 
    return false 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...