Skip to content

Instantly share code, notes, and snippets.

@huseyin
Last active May 16, 2016 00:21
Show Gist options
  • Save huseyin/60d202d64f9410efa68b277ddda74598 to your computer and use it in GitHub Desktop.
Save huseyin/60d202d64f9410efa68b277ddda74598 to your computer and use it in GitHub Desktop.
package main

import "fmt"

Tester

Falan feşmekan

func caser(n string) string {
	return "test durumu: " + n
}

SubTest-1

func caseOne() {
	fmt.Println(caser("1"))
}

Test-2

func main() {
	caseOne()
	fmt.Println(caser("2"))
}

Kapsam Değiştir

Burası

package main

import "fmt"

type tamsayi int32

Şurası

Şöyle böyle...

func (t tamsayi) mutlak() int32 {
	if t < 0 {
		return int32(-t)
	}
	return int32(t)
}

Ana kodlar

Gerek mi?

Dil değiştir

#include <stdio.h>
#include <stdlib.h>

static int mutlak_deger(int);

typedef struct __tamsayisal {
	int (*mutlak)(int);
} Math;

Filandır Falandır

Falandır filandır

Math tamsayisal() {
	Math m;
	m.mutlak = &mutlak_deger;
	return m;
}

static int mutlak_deger(int sayi) {
	if (sayi < 0)
		return -sayi;
	return sayi;
}

Tekrar Kapsam Değiştir

Main için burası

int main() {
	Math math = tamsayisal();
	
	printf("mutlak değeri: %d", math.mutlak(3));
	
	return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment