From 4abce50bfeab63cfb1b66acbf1622a47d85b3a2a Mon Sep 17 00:00:00 2001 From: m90 Date: Mon, 11 Aug 2014 10:02:06 +0200 Subject: add german coffeescript introduction --- de-de/coffeescript-de.html.markdown | 104 ++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 de-de/coffeescript-de.html.markdown (limited to 'de-de') diff --git a/de-de/coffeescript-de.html.markdown b/de-de/coffeescript-de.html.markdown new file mode 100644 index 00000000..5a5ccbde --- /dev/null +++ b/de-de/coffeescript-de.html.markdown @@ -0,0 +1,104 @@ +--- +language: coffeescript +contributors: + - ["Tenor Biel", "http://github.com/L8D"] + - ["Xavier Yao", "http://github.com/xavieryao"] +translators: + - ["Frederik Ring", "https://github.com/m90"] +filename: coffeescript-de.coffee +lang: de-de +--- + +CoffeeScript ist eine kleine Sprache die eins zu eins nach JavaScript transpiliert wird, es gibt keinen Laufzeitinterpreter für sie. +Als Nachfolger von JavaScript konzipiert, gibt CoffeeScript sein Bestes lesbaren, gut formatierten und effizienten JavaScript-Code zu erzeugen der in allen Laufzeiten einwandfrei funktioniert. + +Auf [der CoffeeScript Website](http://coffeescript.org/) gibt es ein ausführliches Tutorial. + +``` coffeescript +# CoffeeScript ist eine dieser Sprachen für "Hipster" +# und folgt daher vielen Trends und Einflüssen aus modernen Sprachen. +# Kommentare werden daher wie in Ruby und Python mit Hashes gekennzeichnet + +### +Kommentarblöcke sehen aus wie diese und werden direkt nach '/ *s und '* /s im erzeugten JavaScript transpiliert. + +Vorweg: bevor du mit CoffeeScript anfängst solltest du einen guten Überblick +über die Eigenheiten von JavaScript an sich haben. +### + +# Zuweisung: +number = 42 #=> var number = 42; +opposite = true #=> var opposite = true; + +# Bedingungen: +number = -42 if opposite #=> if(opposite) { number = -42; } + +# Funktionen: +square = (x) -> x * x #=> var square = function(x) { return x * x; } + +fill = (container, liquid = "Kaffee") -> + "#{container} wird mit #{liquid} gefüllt..." +#=>var fill; +# +#fill = function(container, liquid) { +# if (liquid == null) { +# liquid = "Kaffee"; +# } +# return container + " wird mit " + liquid + " gefüllt..."; +#}; + +# "Ranges": +list = [1..5] #=> var list = [1, 2, 3, 4, 5]; + +# Objekte: +math = + root: Math.sqrt + square: square + cube: (x) -> x * square x +#=> var math = { +# "root": Math.sqrt, +# "square": square, +# "cube": function(x) { return x * square(x); } +#} + +# "Splats": +race = (winner, runners...) -> + print winner, runners +#=>race = function() { +# var runners, winner; +# winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : []; +# return print(winner, runners); +#}; + +# Existenz-Operator: +alert "Hab ich's nicht gesagt?" if elvis? +#=> if(typeof elvis !== "undefined" && elvis !== null) { alert("Hab ich's nicht gesagt?"); } + +# Collection-Mapping: +cubes = (math.cube num for num in list) +#=>cubes = (function() { +# var _i, _len, _results; +# _results = []; +# for (_i = 0, _len = list.length; _i < _len; _i++) { +# num = list[_i]; +# _results.push(math.cube(num)); +# } +# return _results; +# })(); + +foods = ['Brokkoli', 'Spinat', 'Schokolade'] +eat food for food in foods when food isnt 'Schokolade' +#=>foods = ['Brokkoli', 'Spinat', 'Schokolade']; +# +#for (_k = 0, _len2 = foods.length; _k < _len2; _k++) { +# food = foods[_k]; +# if (food !== 'Schokolade') { +# eat(food); +# } +#} +``` + +## Weiterführende Links + +- [Smooth CoffeeScript](http://autotelicum.github.io/Smooth-CoffeeScript/) +- [CoffeeScript Ristretto](https://leanpub.com/coffeescript-ristretto/read) -- cgit v1.2.3