2015-11-09 08:01:19 -08:00
<!DOCTYPE html>
< html >
< head >
< meta http-equiv = "Content-type" content = "text/html;charset=UTF-8" / >
< title > Object Class – Wren< / title >
< link rel = "stylesheet" type = "text/css" href = "../../style.css" / >
< link href = '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel = 'stylesheet' type = 'text/css' >
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
the viewport. -->
< meta name = "viewport" content = "width=device-width, initial-scale=1, maximum-scale=1" / >
< / head >
< body id = "top" class = "module" >
< header >
< div class = "page" >
< div class = "main-column" >
< h1 > < a href = "../../" > wren< / a > < / h1 >
< h2 > a classy little scripting language< / h2 >
< / div >
< / div >
< / header >
< div class = "page" >
< nav class = "big" >
< ul >
< li > < a href = "../" > Modules< / a > < / li >
< li > < a href = "./" > core< / a > < / li >
< / ul >
< section >
< h2 > core classes< / h2 >
< ul >
< li > < a href = "bool.html" > Bool< / a > < / li >
< li > < a href = "class.html" > Class< / a > < / li >
< li > < a href = "fiber.html" > Fiber< / a > < / li >
< li > < a href = "fn.html" > Fn< / a > < / li >
< li > < a href = "list.html" > List< / a > < / li >
< li > < a href = "map.html" > Map< / a > < / li >
< li > < a href = "null.html" > Null< / a > < / li >
< li > < a href = "num.html" > Num< / a > < / li >
< li > < a href = "object.html" > Object< / a > < / li >
< li > < a href = "range.html" > Range< / a > < / li >
< li > < a href = "sequence.html" > Sequence< / a > < / li >
< li > < a href = "string.html" > String< / a > < / li >
< li > < a href = "system.html" > System< / a > < / li >
< / ul >
< / section >
< / nav >
< nav class = "small" >
< table >
< tr >
< td > < a href = "../" > Modules< / a > < / td >
< td > < a href = "./" > core< / a > < / td >
< / tr >
< tr >
< td colspan = "2" > < h2 > core classes< / h2 > < / td >
< / tr >
< tr >
< td >
< ul >
< li > < a href = "bool.html" > Bool< / a > < / li >
< li > < a href = "class.html" > Class< / a > < / li >
< li > < a href = "fiber.html" > Fiber< / a > < / li >
< li > < a href = "fn.html" > Fn< / a > < / li >
< li > < a href = "list.html" > List< / a > < / li >
< li > < a href = "map.html" > Map< / a > < / li >
< li > < a href = "null.html" > Null< / a > < / li >
< / ul >
< / td >
< td >
< ul >
< li > < a href = "num.html" > Num< / a > < / li >
< li > < a href = "object.html" > Object< / a > < / li >
< li > < a href = "range.html" > Range< / a > < / li >
< li > < a href = "sequence.html" > Sequence< / a > < / li >
< li > < a href = "string.html" > String< / a > < / li >
< li > < a href = "system.html" > System< / a > < / li >
< / ul >
< / td >
< / tr >
< / table >
< / nav >
< main >
< h1 > Object Class< / h1 >
< h2 > Static Methods < a href = "#static-methods" name = "static-methods" class = "header-anchor" > #< / a > < / h2 >
< h3 > < strong > same< / strong > (obj1, obj2) < a href = "#same(obj1,-obj2)" name = "same(obj1,-obj2)" class = "header-anchor" > #< / a > < / h3 >
< p > Returns < code > true< / code > if < em > obj1< / em > and < em > obj2< / em > are the same. For < a href = "../values.html" > value
types< / a > , this returns < code > true< / code > if the objects have equivalent
state. In other words, numbers, strings, booleans, and ranges compare by value. < / p >
< p > For all other objects, this returns < code > true< / code > only if < em > obj1< / em > and < em > obj2< / em > refer to
the exact same object in memory. < / p >
< p > This is similar to the built in < code > ==< / code > operator in Object except that this cannot
be overriden. It allows you to reliably access the built-in equality semantics
even on user-defined classes. < / p >
< h2 > Methods < a href = "#methods" name = "methods" class = "header-anchor" > #< / a > < / h2 >
< h3 > < strong > !< / strong > operator < a href = "#-operator" name = "-operator" class = "header-anchor" > #< / a > < / h3 >
< p > Returns < code > false< / code > , since most objects are considered < a href = "control-flow.html#truth" > true< / a > . < / p >
< h3 > < strong > ==< / strong > (other) and < strong > !=< / strong > (other) operators < a href = "#==(other)-and-=(other)-operators" name = "==(other)-and-=(other)-operators" class = "header-anchor" > #< / a > < / h3 >
< p > Compares two objects using built-in equality. This compares < a href = "../values.html" > value
types< / a > by value, and all other objects are compared by
identity— two objects are equal only if they are the exact same object. < / p >
< h3 > < strong > is< / strong > (class) operator < a href = "#is(class)-operator" name = "is(class)-operator" class = "header-anchor" > #< / a > < / h3 >
< p > Returns < code > true< / code > if this object’ s class or one of its superclasses is < code > class< / code > . < / p >
2017-10-19 07:05:45 -07:00
< div class = "codehilite" > < pre > < span > < / span > < span class = "vg" > System< / span > < span class = "o" > .< / span > < span class = "n" > print< / span > < span class = "p" > (< / span > < span class = "mi" > 123< / span > < span class = "k" > is< / span > < span class = "vg" > Num< / span > < span class = "p" > )< / span > < span class = "output" > true< / span >
2015-11-09 08:01:19 -08:00
< span class = "vg" > System< / span > < span class = "o" > .< / span > < span class = "n" > print< / span > < span class = "p" > (< / span > < span class = "s" > " s" < / span > < span class = "k" > is< / span > < span class = "vg" > Num< / span > < span class = "p" > )< / span > < span class = "output" > false< / span >
< span class = "vg" > System< / span > < span class = "o" > .< / span > < span class = "n" > print< / span > < span class = "p" > (< / span > < span class = "kc" > null< / span > < span class = "k" > is< / span > < span class = "vg" > String< / span > < span class = "p" > )< / span > < span class = "output" > false< / span >
< span class = "vg" > System< / span > < span class = "o" > .< / span > < span class = "n" > print< / span > < span class = "p" > ([]< / span > < span class = "k" > is< / span > < span class = "vg" > List< / span > < span class = "p" > )< / span > < span class = "output" > true< / span >
< span class = "vg" > System< / span > < span class = "o" > .< / span > < span class = "n" > print< / span > < span class = "p" > ([]< / span > < span class = "k" > is< / span > < span class = "vg" > Sequence< / span > < span class = "p" > )< / span > < span class = "output" > true< / span >
< / pre > < / div >
< p > It is a runtime error if < code > class< / code > is not a < a href = "class.html" > Class< / a > . < / p >
< h3 > < strong > toString< / strong > < a href = "#tostring" name = "tostring" class = "header-anchor" > #< / a > < / h3 >
< p > A default string representation of the object. < / p >
< h3 > < strong > type< / strong > < a href = "#type" name = "type" class = "header-anchor" > #< / a > < / h3 >
< p > The < a href = "class.html" > Class< / a > of the object. < / p >
< / main >
< / div >
< footer >
< div class = "page" >
< div class = "main-column" >
< p > Wren lives
< a href = "https://github.com/munificent/wren" > on GitHub< / a >
— Made with ❤ by
< a href = "http://journal.stuffwithstuff.com/" > Bob Nystrom< / a > and
< a href = "https://github.com/munificent/wren/blob/master/AUTHORS" > friends< / a > .
< / p >
< div class = "main-column" >
< / div >
< / footer >
< / body >
< / html >