Skip to content

Instantly share code, notes, and snippets.

@donatj
Last active August 7, 2017 21:47
Show Gist options
  • Save donatj/13fb4f2dfbef7dc3c1f8961eb4a7a31d to your computer and use it in GitHub Desktop.
Save donatj/13fb4f2dfbef7dc3c1f8961eb4a7a31d to your computer and use it in GitHub Desktop.

TypeScript

class MyLogicContainer {
    constructor(private x: number) { }
    
    add(y: number) {
        return this.x + y;
    }
}

JavaScript

var MyLogicContainer = (function () {
    function MyLogicContainer(x) {
        this.x = x;
    }
    MyLogicContainer.prototype.add = function (y) {
        return this.x + y;
    };
    return MyLogicContainer;
}());

PHP

<?php

class MyLogicContainer {
	protected $x;

	public function __construct($x) {
		$this->x = $x;
	}
    
	public function add($y) {
		return $this->x + $y;
	}
}

Go

type MyLogicContainer struct {
	x float64
}

func NewMyLogicContainer(x float64) *MyLogicContainer {
	return &MyLogicContainer{x: x}
}

func (m *MyLogicContainer) add(y float64) float64 {
	return m.x + y
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment