Ring Documentation Walkthrough #10 – Check Data Types 1

Welcome to the chapter 10, you’ve made a lot of progress.

We will learn in this post five important functions for checking types of objects, and they’re :

  • isString() & isNumber()
    see isString('amr') #output: 1 (true)
    see isString(1) #output: 0 (false)
    see isNumber(1) #output: 1 (true)
  • isList()
    see isList( [1, 2, 3] ) #output: 1 (true)
    see isList( 'amr' ) #output: 0 (false)
  • isNull()
    x = ''
    see isNull(x) #output: 1 (true)
    see isNull('NULL') #output: 1 (true)
    see isNull(2) #output: 0 (false)
    see isNull( [1, 2, 3] ) #output: 0 (false)
    see isNull('Null') #output: 0 (false)
  • type()
    see type( 'amr' ) #output: STRING
    see type(1) #output: NUMBER
    see type( [1, 2, 3] ) #output: LIST
    see type('') #output: STRING
    see type('NULL') #output: STRING
    see type(true) #output: NUMBER, because true equals 1
    see type(false) #output: NUMBER, because false equals 0

Will be continued in the next post …



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s