Type detection: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
No edit summary
Line 9: Line 9:
console.log(typeof(12345)); // Returns number
console.log(typeof(12345)); // Returns number
</pre>
</pre>

== OASYS Assembler ==

<lang oasys_oaa>
; The following method checks if a global variable or property is an
; object type. Does not work with locals and arguments.

[&OBJ#,^]
,^<,^<< ; Remember old value
,^<*> ; Create new object
,^<<DES ; Destroy the object
,^<<EX ; Check if variable has been cleared
/>1RF ; It is clear
:>0RF ; It is not clear
</lang>


== PHP ==
== PHP ==


[https://secure.php.net/manual/en/function.gettype.php]
[http://php.net/manual/en/function.gettype.php]


<pre>
<pre>
Line 21: Line 36:
=== Specific tester functions ===
=== Specific tester functions ===


* [https://secure.php.net/manual/en/function.is-array.php is_array()]
* [http://php.net/manual/en/function.is-array.php is_array()]

Revision as of 02:35, 9 October 2015

Type detection is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

This draft task needs a purpose, a description and some way to tell whether examples satisfy or do not satisfy it.

JavaScript

[1]

console.log(typeof('foo')); // Returns string
console.log(typeof(12345)); // Returns number

OASYS Assembler

<lang oasys_oaa>

The following method checks if a global variable or property is an
object type. Does not work with locals and arguments.

[&OBJ#,^]

 ,^<,^<<    ; Remember old value
 ,^<*>      ; Create new object
 ,^<<DES    ; Destroy the object
 ,^<<EX     ; Check if variable has been cleared
 />1RF      ; It is clear
 :>0RF      ; It is not clear

</lang>

PHP

[2]

echo gettype('foo'); // Returns string
echo gettype(12345); // Returns integer

Specific tester functions