28 lines
		
	
	
		
			331 B
		
	
	
	
		
			ChaiScript
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			331 B
		
	
	
	
		
			ChaiScript
		
	
	
	
	
	
 | 
						|
class Vector3
 | 
						|
{
 | 
						|
  // you can use attr, auto or var in this context
 | 
						|
  attr x
 | 
						|
  auto y
 | 
						|
  var z
 | 
						|
 | 
						|
  def Vector3(x,y,z)
 | 
						|
  {
 | 
						|
    this.x = x
 | 
						|
    this.y = y
 | 
						|
    this.z = z
 | 
						|
  }
 | 
						|
 | 
						|
  def doSomething(mult)
 | 
						|
  {
 | 
						|
    return this.x * this.y * this.z * mult
 | 
						|
  }
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
auto v = Vector3(1,2,3)
 | 
						|
assert_equal(1, v.x)
 | 
						|
assert_equal(v.doSomething(2), 12)
 | 
						|
 |