summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cs-cz/python3.html.markdown2
-rw-r--r--d.html.markdown8
-rw-r--r--es-es/python3-es.html.markdown2
-rw-r--r--fr-fr/javascript-fr.html.markdown264
-rw-r--r--fr-fr/python3-fr.html.markdown2
-rw-r--r--json.html.markdown51
-rw-r--r--ru-ru/python3-ru.html.markdown2
-rw-r--r--ruby.html.markdown4
-rw-r--r--sass.html.markdown203
-rw-r--r--tr-tr/python3-tr.html.markdown2
-rw-r--r--zh-cn/python3-cn.html.markdown2
11 files changed, 368 insertions, 174 deletions
diff --git a/cs-cz/python3.html.markdown b/cs-cz/python3.html.markdown
index 6d2fd1eb..b498046a 100644
--- a/cs-cz/python3.html.markdown
+++ b/cs-cz/python3.html.markdown
@@ -566,7 +566,7 @@ Clovek.odkaslej_si() # => "*ehm*"
# Lze importovat moduly
import math
-print(math.sqrt(16)) # => 4
+print(math.sqrt(16.0)) # => 4
# Lze také importovat pouze vybrané funkce z modulu
from math import ceil, floor
diff --git a/d.html.markdown b/d.html.markdown
index 6f3710ab..9ebba385 100644
--- a/d.html.markdown
+++ b/d.html.markdown
@@ -53,15 +53,15 @@ void main() {
// For and while are nice, but in D-land we prefer 'foreach' loops.
// The '..' creates a continuous range, including the first value
// but excluding the last.
- foreach(i; 1..1_000_000) {
+ foreach(n; 1..1_000_000) {
if(n % 2 == 0)
- writeln(i);
+ writeln(n);
}
// There's also 'foreach_reverse' when you want to loop backwards.
- foreach_reverse(i; 1..int.max) {
+ foreach_reverse(n; 1..int.max) {
if(n % 2 == 1) {
- writeln(i);
+ writeln(n);
} else {
writeln("No!");
}
diff --git a/es-es/python3-es.html.markdown b/es-es/python3-es.html.markdown
index 1c69481a..d30af1c8 100644
--- a/es-es/python3-es.html.markdown
+++ b/es-es/python3-es.html.markdown
@@ -478,7 +478,7 @@ Humano.roncar() #=> "*roncar*"
# Puedes importar módulos
import math
-print(math.sqrt(16)) #=> 4
+print(math.sqrt(16)) #=> 4.0
# Puedes obtener funciones específicas desde un módulo
from math import ceil, floor
diff --git a/fr-fr/javascript-fr.html.markdown b/fr-fr/javascript-fr.html.markdown
index 15478cdb..f1977dac 100644
--- a/fr-fr/javascript-fr.html.markdown
+++ b/fr-fr/javascript-fr.html.markdown
@@ -6,23 +6,26 @@ contributors:
filename: javascript-fr.js
translators:
- ['@nbrugneaux', 'https://nicolasbrugneaux.me']
+ - ['Michel Antoine', 'https://github.com/antoin-m']
lang: fr-fr
---
JavaScript a été créé par Brendan Eich, travaillant alors a Netscape, en 1995.
Le langage avait à l'origine pour but d'être un langage de scripting simple
pour les sites web, complétant le Java (à ne pas confondre avec JavaScript)
-pour des applications web complexes. Mais son intégration très proche et
-simple des pages web, ainsi que le support natif des navigateurs a rendu
-le JavaScript incontournable aujourd'hui tant bien dans le front-end que
+pour des applications web complexes. Mais son intégration très proche et
+simple des pages web, ainsi que le support natif des navigateurs a rendu
+le JavaScript incontournable aujourd'hui tant bien dans le front-end que
dans le back-end.
En effet, le JavaScript n'est plus uniquement limité aux navigateurs, grâce à
-Node.JS, un projet qui offre un environnement indépendant dans lequel un
-interpréteur Javascript, basé sur le célèbre moteur V8 de Google Chrome,
+Node.JS, un projet qui offre un environnement indépendant dans lequel un
+interpréteur Javascript, basé sur le célèbre moteur V8 de Google Chrome,
peut être utilisé directement côté serveur pour exécuter des programmes écrits
en JavaScript.
+ECMAScript (la norme du langage Javascript) entre en version 6. Cette version introduit de nombreuses mises à jour tout en restant rétrocompatible. L'implémentation de ces nouvelles fonctionnalités est en cours et celles-ci ne sont donc pas forcément compatibles avec tous les navigateurs.
+
```js
// Les commentaires sont comme en C. Les commentaires mono-ligne commencent par 2 slashs,
/* et les commentaires sur plusieurs lignes commencent avec slash-étoile
@@ -31,7 +34,7 @@ en JavaScript.
// Toutes les expressions peuvent finir par ;
doStuff();
-// ... mais n'en n'ont pas forcément besoin, les point-virgules sont ajoutés
+// ... mais n'en n'ont pas forcément besoin, les point-virgules sont ajoutés
// lors de l’interprétation aux sauts de ligne, sauf exceptions
doStuff()
@@ -79,6 +82,12 @@ false; // faux
"abc";
'Hello, world';
+// *ES6:* Les chaines de caractères peuvent être crées en utilisant un modèle
+// entouré des quotes inverses (`) à la place des quotes classiques (' ou ").
+// Les variables sont interprétées avec ${var}
+let banta = "Harry", santa = "Hermione";
+`${banta}, your santa is ${santa}.` // = "Harry, your santa is Hermione."
+
// La négation utilise le symbole !
!true; // = false
!false; // = true
@@ -117,26 +126,34 @@ false; // faux
// Il y a également null et undefined
null; // utilisé pour une non-valeur
-undefined; // utilisé pour une valeur actuellement non présente (cependant,
+undefined; // utilisé pour une valeur actuellement non présente (cependant,
// undefined est aussi une valeur valide)
// false, null, undefined, NaN, 0 and '' sont 'presque-faux' (falsy), tout le reste
// est 'presque-vrai' (truthy)
// Notez que 0 est falsy mais '0' est truthy, alors même que 0 == '0' (mais 0 !== '0')
+// *ES6:* Introduction d'un nouveau type primitif : Symbol
+var symbol_one = Symbol();
+var symbol_two = Symbol('This is optional description, for debugging');
+typeof symbol_one === 'symbol' // = true
+
+// *ES6:* Un Symbol est immutable et unique
+Symbol() === Symbol() // = false
+Symbol('learnx') === Symbol('learnx') // = false
///////////////////////////////////
-// 2. Variables, Tableaux et Objets
+// 2. Variables, Tableaux, Objets, Maps et Sets
-// Les variables sont déclarées avec le mot clé var. Le typage en JavaScript est
+// Les variables sont déclarées avec le mot clé var. Le typage en JavaScript est
// dynamique, donc pas besoin de spécifier le type. L'assignement utilise un seul =.
var someVar = 5;
// si vous oubliez le mot clé var, vous n'aurez pas d'erreur (sauf en mode strict)
someOtherVar = 10;
-// ... mais la variable aura une portée globale (plus communément trouvé en tant
-// que "global scope" en anglais), et non pas une portée limitée à la fonction
+// ... mais la variable aura une portée globale (plus communément trouvé en tant
+// que "global scope" en anglais), et non pas une portée limitée à la fonction
// dans laquelle vous l'aviez définie.
// Les variables déclarées et non assignées sont undefined par défaut
@@ -145,6 +162,32 @@ var someThirdVar = undefined;
// ... sont deux déclarations identiques.
+// Il est possible de déclarer plusieurs variables en séparant leur déclaration
+// avec l'opérateur virgule
+var someFourthVar = 2, someFifthVar = 4;
+
+// *ES6:* Les variables peuvent maintenant être déclarées avec les mots-clés
+// `let` et `const`
+let someSixthVar = 6;
+const someSeventhVar = 7;
+
+// *ES6:* Le mot-clé `let` attache la variable au block de code et non à la fonction
+// à l'inverse de `var`
+for (let i = 0; i < 10; i++) {
+ x += 10;
+}
+i; // = raises ReferenceError
+
+// *ES6:* Les variables "const" doivent être assignées lors de l'initialisation
+const someEighthVar = 7;
+const someNinthVar; // raises SyntaxError
+
+// *ES6:* Modifier une variable constante ne lève par d'erreur mais échoue
+// silencieusement
+const someNinthVar = 9;
+someNinthVar = 10;
+someNinthVar; // = 9
+
// Il y a des raccourcis pour les opérations mathématiques:
someVar += 5; // équivalent pour someVar = someVar + 5;
someVar *= 10; // de même, someVar = someVar * 100;
@@ -165,6 +208,22 @@ myArray.length; // = 4
// Ajout/Modification à un index spécifique
myArray[3] = 'Hello';
+// *ES6:* Les Arrays peuvent maintenant être déstructurés en utilisant le pattern matching
+var [a, b] = [1, 2];
+var [a, , b] = [1, -2, 2]
+
+a; // = 1
+b; // = 2
+
+// *ES6:* La déstructuration peut échouer silencieusement.
+// Il est aussi possible d'utiliser des valeurs par défaut
+var [a] = [];
+a; // = undefined;
+var [a = 1] = [];
+a; // = 1;
+var [a = 1] = [2];
+a; // = 2;
+
// Les objets JavaScript sont appelés 'dictionnaires' ou 'maps' dans certains autres
// langages : ils sont une liste non-ordonnée de paires clé-valeur.
var myObj = {key1: 'Hello', key2: 'World'};
@@ -179,12 +238,55 @@ myObj['my other key']; // = 4
// .. ou avec un point si la clé est un identifiant valide.
myObj.myKey; // = 'myValue'
+// *ES6:* Un Symbol peut être utilisé en tant que clé. Puisque ceux-ci sont uniques,
+// le seul moyen d'accéder à la propriété est d'avoir une référence sur ce Symbol.
+myObj["key"] = "public value";
+myObj[Symbol("key")] = "secret value";
+myObj[Symbol("key")]; // = undefined
+
// Les objets sont eux aussi modifiables.
myObj.myThirdKey = true;
// Si vous essayez d'accéder à une valeur non-définie, vous obtiendrez undefined
myObj.myFourthKey; // = undefined
+// *ES6:* Comme les Arrays, les Objects peuvent être déstructurés en utilisant le pattern matching
+var {foo} = {foo: "bar"};
+foo // = "bar"
+
+// *ES6:* Les Objects déstructurés peuvent utiliser des noms de variables différents
+// de ceux d'origine grâce au pattern matching
+var {foo, moo: baz} = {foo: "bar", moo: "car"};
+foo // = "bar"
+baz // = "car"
+
+// *ES6:* Il est possible d'utiliser des valeurs par défaut lor de la déstructuration d'un Object
+var {foo="bar"} = {moo: "car"};
+foo // = "bar"
+
+// *ES6:* Une erreur lors de la déstructuration restera silencieuse
+var {foo} = {};
+foo // = undefined
+
+// *ES6:* Les Maps sont des objets itérables de type clé-valeur.
+// Il est possible de créer une nouvelle map en utilisant `new Map()`
+var myMap = new Map();
+
+// *ES6:* Il est possible d'ajouter un couple clé-valeur avec la méthode `.set()`,
+// de récupérer une valeur avec `.get()`,
+// de vérifier qu'une clé existe avec `.has()`
+// et enfin de supprimer un couple clé-valeur avec `.delete()`
+
+myMap.set("name", "Douglas");
+myMap.get("name"); // = "Douglas"
+myMap.has("name"); // = true
+myMap.delete("name");
+
+// *ES6:* Les Sets sont des ensembles de valeurs uniques.
+// Il est possible de créer un set avec `new Set()`.
+// Toute valeur non unique est ignorée.
+var mySet = new Set([1,2,2]);
+console.log([...mySet]); // = [1,2]
///////////////////////////////////
// 3. Logique et structures de contrôle
@@ -198,7 +300,7 @@ else if (count === 4) {
// uniquement quand count est 4
}
else {
- // le reste du temps, si ni 3, ni 4.
+ // le reste du temps, si ni 3, ni 4.
}
// De même pour while.
@@ -218,6 +320,22 @@ for (var i = 0; i < 5; i++){
// sera exécutée 5 fois
}
+// La boucle for...in permet d'itérer sur les noms des propriétés d'un objet
+var description = "";
+var person = {fname:"Paul", lname:"Ken", age:18};
+for (var x in person){
+ description += person[x] + " ";
+}
+description; // = "Paul Ken 18 "
+
+// *ES6:* La boucle for...of permet d'itérer sur les propriétés d'un objet
+var description = "";
+var person = {fname:"Paul", lname:"Ken", age:18};
+for (var x of person){
+ description += x + " ";
+}
+description; // = "Paul Ken 18 "
+
// && est le "et" logique, || est le "ou" logique
if (house.size === 'big' && house.colour === 'blue'){
house.contains = 'bear';
@@ -264,7 +382,21 @@ function myFunction(thing){
}
myFunction('foo'); // = 'FOO'
-// Les fonctions JavaScript sont des objets de première classe, donc peuvent
+// Attention, la valeur à retourner doit se trouver sur la même ligne que
+// le mot-clé `return` sinon la fonction retournera systématiquement `undefined`
+function myFunction(){
+ return // <- semicolon automatically inserted here
+ {thisIsAn: 'object literal'}
+}
+myFunction(); // = undefined
+
+// *ES6:* Les paramètres des fonctions peuvent désormais avoir des valeurs par défaut
+function default(x, y = 2) {
+ return x + y;
+}
+default(10); // == 12
+
+// Les fonctions JavaScript sont des objets de première classe, donc peuvent
// être réassignées à d'autres variables et passées en tant que paramètres pour
// d'autres fonctions
function myFunction(){
@@ -274,13 +406,17 @@ setTimeout(myFunction, 5000);
// Note: setTimeout ne fait pas parti du langage, mais les navigateurs ainsi
// que Node.js le rendent disponible
-// Les fonctions n'ont pas nécessairement besoin d'un nom, elles peuvent être
+// Les fonctions n'ont pas nécessairement besoin d'un nom, elles peuvent être
// anonymes
setTimeout(function(){
// ce code s'exécutera dans 5 secondes
}, 5000);
-// Le Javascript crée uniquement un scope, une portée d'action limitée, pour
+// *ES6:* Introduction d'un sucre syntaxique permettant de créer
+// une fonction anonyme de la forme : `param => returnValue`.
+setTimeout(() => console.log('5 seconds, are up.'), 5000);
+
+// Le Javascript crée uniquement un scope, une portée d'action limitée, pour
// les fonctions, et pas dans les autres blocs.
if (true){
var i = 5;
@@ -293,7 +429,7 @@ i; // = 5 - et non undefined comme vous pourriez vous y attendre
var temporary = 5;
// Nous pouvons accéder au scope global en assignant à l'objet global,
// qui dans les navigateurs est "window". Il est différent dans Node.js,
- // le scope global sera en fait local au module dans lequel vous
+ // le scope global sera en fait local au module dans lequel vous
// vous trouvez. http://nodejs.org/api/globals.html
window.permanent = 10;
})();
@@ -302,8 +438,8 @@ i; // = 5 - et non undefined comme vous pourriez vous y attendre
temporary; // raises ReferenceError
permanent; // = 10
-// Une des fonctionnalités les plus puissantes de Javascript est le système de
-// closures. Si une fonction est définie dans une autre fonction, alors la
+// Une des fonctionnalités les plus puissantes de Javascript est le système de
+// closures. Si une fonction est définie dans une autre fonction, alors la
// fonction interne aura accès aux variables de la fonction parente, même si
// celle-ci a déjà finie son exécution.
function sayHelloInFiveSeconds(name){
@@ -318,6 +454,18 @@ function sayHelloInFiveSeconds(name){
}
sayHelloInFiveSeconds('Adam'); // ouvre un popup avec 'Hello, Adam!' dans 5sec
+// *ES6:* Les paramètres des fonctions appelées avec un tableau en entré
+// préfixé par `...` vont se peupler avec les éléments du tableau
+function spread(x, y, z) {
+ return x + y + z;
+}
+spread(...[1,2,3]); // == 6
+
+// *ES6:* Les fonctions peuvent recevoir les paramètres dans un tableau en utilisant l'opérateur `...`
+function spread(x, y, z) {
+ return x + y + z;
+}
+spread(...[1,2,3]); // == 6
///////////////////////////////////
// 5. Encore plus à propos des Objets; Constructeurs and Prototypes
@@ -340,7 +488,7 @@ myObj = {
};
myObj.myFunc(); // = 'Hello world!'
-// La valeur de "this" change de par l'endroit où la fonction est appelée, et
+// La valeur de "this" change de par l'endroit où la fonction est appelée, et
// non de l'endroit où elle est définie. Donc elle ne fonctionnera pas si elle
// est appelée hors du contexte l'objet.
var myFunc = myObj.myFunc;
@@ -356,7 +504,7 @@ myObj.myOtherFunc = myOtherFunc;
myObj.myOtherFunc(); // = 'HELLO WORLD!'
// Le contexte correspond à la valeur de "this".
-// Nous pouvons aussi spécifier un contexte, forcer la valeur de "this,
+// Nous pouvons aussi spécifier un contexte, forcer la valeur de "this,
// pour une fonction quand elle est appelée grâce à "call" ou "apply".
var anotherFunc = function(s){
return this.myString + s;
@@ -371,19 +519,19 @@ Math.min(42, 6, 27); // = 6
Math.min([42, 6, 27]); // = NaN (uh-oh!)
Math.min.apply(Math, [42, 6, 27]); // = 6
-// Mais, "call" and "apply" fonctionnenent uniquement au moment de l'appel de la
-// fonction. Pour lier le contexte de façon permanente, nous pouvons utiliser
+// Mais, "call" and "apply" fonctionnenent uniquement au moment de l'appel de la
+// fonction. Pour lier le contexte de façon permanente, nous pouvons utiliser
// "bind" pour garder une référence à la fonction avec ce "this".
var boundFunc = anotherFunc.bind(myObj);
boundFunc(' And Hello Saturn!'); // = 'Hello World! And Hello Saturn!'
-// "bind" peut aussi être utilisé pour créer une application partielle de la
+// "bind" peut aussi être utilisé pour créer une application partielle de la
// fonction (curry)
var product = function(a, b){ return a * b; }
var doubler = product.bind(this, 2);
doubler(8); // = 16
-// Lorsque vous appelez une fonction avec le mot clé "new", un nouvel objet est
+// Lorsque vous appelez une fonction avec le mot clé "new", un nouvel objet est
// crée et mis à disposition de la fonction via "this". Ces fonctions sont
// communément appelées constructeurs.
var MyConstructor = function(){
@@ -395,8 +543,8 @@ myNewObj.myNumber; // = 5
// Chaque objet en Javascript a un "prototype". Quand vous essayez d'accéder à
// une propriété que l'objet n'a pas, l'interpréteur va regarder son prototype.
-// Quelques implémentations de JS vous laissent accéder au prototype avec la
-// propriété "magique" __proto__. Ceci peut être utile, mais n'est pas standard
+// Quelques implémentations de JS vous laissent accéder au prototype avec la
+// propriété "magique" __proto__. Ceci peut être utile, mais n'est pas standard
// et ne fonctionne pas dans certains des navigateurs actuels.
var myObj = {
myString: 'Hello world!'
@@ -478,7 +626,7 @@ String.prototype.firstCharacter = function(){
'abc'.firstCharacter(); // = 'a'
// C'est très souvent utilisé pour le "polyfilling", qui implémente des nouvelles
-// fonctionnalités de JavaScript dans de plus anciens environnements, tels que
+// fonctionnalités de JavaScript dans de plus anciens environnements, tels que
// les vieux navigateurs.
//Par exemple, Object.create est assez récent, mais peut être implémenté grâce à
@@ -492,31 +640,83 @@ if (Object.create === undefined){ // pour ne pas reécrire si la fonction existe
return new Constructor();
}
}
+
+// *ES6:* Les objets peuvent être équipés de proxies qui permettent d'intercepter
+// les actions sur leurs propriétés. Voici comment créer un proxy sur un objet :
+var proxyObject = new Proxy(object, handler);
+
+// *ES6:* Les méthodes d'un objet handler sont appelées lors de l'interception d'une action.
+// La méthode `.get()` est appelée à chaque lecture d'une propriété
+// tandis que la méthode `.set()` est appelée à chaque écriture.
+var handler = {
+ get (target, key) {
+ console.info('Get on property' + key);
+ return target[key];
+ },
+ set (target, key, value) {
+ console.info('Set on property' + key);
+ return true;
+ }
+}
+
+// *ES6:* Les classes peuvent désormais être définies en utilisant le mot-clé `class`.
+// Le constructeur s'appelle `constructor` et les méthodes statiques utilisent le mot-clé `static`
+class Foo {
+ constructor() {console.log("constructing Foo");}
+ bar() {return "bar";}
+ static baz() {return "baz";}
+}
+
+// *ES6:* Les objets issus des classes sont initialisés avec le mot-clé `new`.
+// Il est possible d'hériter d'une classe avec le mot-clé `extends`
+var FooObject = new Foo(); // = "constructing Foo"
+class Zoo extends Foo {}
+
+// *ES6:* Les méthodes statiques doivent être appelées par la classe, les autres méthodes par l'objet
+Foo.baz() // = "baz"
+FooObject.bar() // = "bar"
+
+// *ES6:* Il est désormais possible d'exporter des valeurs en tant que module.
+// Les exports peuvent être n'importe quel objet, valeur ou fonction.
+var api = {
+ foo: "bar",
+ baz: "ponyfoo"
+};
+export default api;
+
+// *ES6:* La syntaxe `export default` permet d'exporter l'objet sans en changer le nom.
+// Il y a plusieurs façons de l'importer:
+import coolapi from "api"; // = importe le module dans la variable `coolapi`
+import {foo, baz} from "api"; // = importe les attributs `foo` et `baz` du module
+import {foo as moo, baz} from "api"; // = importe les attributs `foo` (en le renommant `moo`) et `baz` du module
+import _, {map} from "api"; // = importe les exports par défaut ET `map`
+import * as coolapi from "api"; // = importe le namespace global du module
+
```
## Pour aller plus loin (en anglais)
The [Mozilla Developer
Network](https://developer.mozilla.org/fr-FR/docs/Web/JavaScript) expose une
-excellente documentation pour le Javascript dans les navigateurs. Et contient
+excellente documentation pour le Javascript dans les navigateurs. Et contient
également un wiki pour s'entraider.
MDN's [A re-introduction to
JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript)
recouvre les principaux sujets vus ici. Le guide est délibérément uniquement
-à propos du JavaScript, et ne parle pas des navigateurs; pour cela, dirigez vous
+à propos du JavaScript, et ne parle pas des navigateurs; pour cela, dirigez vous
plutôt ici :
[Document Object
Model](https://developer.mozilla.org/en-US/docs/Using_the_W3C_DOM_Level_1_Core)
-[Learn Javascript by Example and with Challenges](http://www.learneroo.com/modules/64/nodes/350) quelques challenges.
+[Learn Javascript by Example and with Challenges](http://www.learneroo.com/modules/64/nodes/350) quelques challenges.
[JavaScript Garden](http://bonsaiden.github.io/JavaScript-Garden/) is an in-depth
un guide pour vous éviter les faux-amis dans le JavaScript.
-[JavaScript: The Definitive Guide](http://www.amazon.com/gp/product/0596805527/) un classique. A lire.
+[JavaScript: The Definitive Guide](http://www.amazon.com/gp/product/0596805527/) un classique. A lire.
-En addition aux contributeurs de cet article, du contenu provient du
+En addition aux contributeurs de cet article, du contenu provient du
"Python tutorial" de Louie Dinh, et de [JS
Tutorial](https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript)
sur le réseau Mozilla.
diff --git a/fr-fr/python3-fr.html.markdown b/fr-fr/python3-fr.html.markdown
index 04d0a55d..3d60157c 100644
--- a/fr-fr/python3-fr.html.markdown
+++ b/fr-fr/python3-fr.html.markdown
@@ -627,7 +627,7 @@ Human.grunt() # => "*grunt*"
# On peut importer des modules
import math
-print(math.sqrt(16)) # => 4
+print(math.sqrt(16)) # => 4.0
# On peut importer des fonctions spécifiques d'un module
from math import ceil, floor
diff --git a/json.html.markdown b/json.html.markdown
index cde7bc40..a612cffe 100644
--- a/json.html.markdown
+++ b/json.html.markdown
@@ -8,27 +8,24 @@ contributors:
- ["Michael Neth", "https://github.com/infernocloud"]
---
-As JSON is an extremely simple data-interchange format, this is most likely going to be the simplest Learn X in Y Minutes ever.
+JSON is an extremely simple data-interchange format. As [json.org](http://json.org) says, it is easy for humans to read and write and for machines to parse and generate.
-JSON in its purest form has no actual comments, but most parsers will accept C-style (`//`, `/* */`) comments. Some parsers also tolerate a trailing comma (i.e. a comma after the last element of an array or the after the last property of an object), but they should be avoided for better compatibility.
-
-For the purposes of this, however, everything is going to be 100% valid JSON. Luckily, it kind of speaks for itself.
-
-A JSON value must be a number, a string, an array, an object, or one of the following 3 literal names: true, false, null.
-
-Supporting browsers are: Firefox 3.5+, Internet Explorer 8.0+, Chrome 1.0+, Opera 10.0+, and Safari 4.0+.
-
-File extension for JSON files is ".json" and the MIME type for JSON text is "application/json".
+A piece of JSON must represent either:
+* A collection of name/value pairs (`{ }`). In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
+* An ordered list of values (`[ ]`). In various languages, this is realized as an array, vector, list, or sequence.
+ an array/list/sequence (`[ ]`) or a dictionary/object/associated array (`{ }`).
-Many programming languages have support for serializing (encoding) and unserializing (decoding) JSON data into native data structures. Javascript has implicit support for manipulating JSON text as data.
+JSON in its purest form has no actual comments, but most parsers will accept C-style (`//`, `/* */`) comments. Some parsers also tolerate a trailing comma (i.e. a comma after the last element of an array or the after the last property of an object), but they should be avoided for better compatibility.
-More information can be found at http://www.json.org/
+For the purposes of this tutorial, everything is going to be 100% valid JSON. Luckily, it kind of speaks for itself.
-JSON is built on two structures:
-* A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
-* An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
+Supported data types:
-An object with various name/value pairs.
+* Strings: `"hello"`, `"\"A quote.\""`, `"\u0abe"`, `"Newline.\n"`
+* Numbers: `23`, `0.11`, `12e10`, `3.141e-10`, `1.23e+4`
+* Objects: `{ "key": "value" }`
+* Arrays: `["Values"]`
+* Miscellaneous: `true`, `false`, `null`
```json
{
@@ -66,20 +63,20 @@ An object with various name/value pairs.
"alternative style": {
"comment": "check this out!"
- , "comma position": "doesn't matter - as long as it's before the next key, then it's valid"
+ , "comma position": "doesn't matter, if it's before the next key, it's valid"
, "another comment": "how nice"
- }
-}
-```
+ },
-A single array of values by itself is also valid JSON.
-```json
-[1, 2, 3, "text", true]
-```
-Objects can be a part of the array as well.
+ "whitespace": "Does not matter.",
-```json
-[{"name": "Bob", "age": 25}, {"name": "Jane", "age": 29}, {"name": "Jack", "age": 31}]
+
+
+ "that was short": "And done. You now know everything JSON has to offer."
+}
```
+
+## Further Reading
+
+* [JSON.org](http://json.org) All of JSON beautifully explained using flowchart-like graphics.
diff --git a/ru-ru/python3-ru.html.markdown b/ru-ru/python3-ru.html.markdown
index 2a7b3f7b..2b6b59a7 100644
--- a/ru-ru/python3-ru.html.markdown
+++ b/ru-ru/python3-ru.html.markdown
@@ -549,7 +549,7 @@ Human.grunt() #=> "*grunt*"
# Вы можете импортировать модули
import math
-print(math.sqrt(16)) #=> 4
+print(math.sqrt(16)) #=> 4.0
# Вы можете импортировать отдельные функции модуля
from math import ceil, floor
diff --git a/ruby.html.markdown b/ruby.html.markdown
index 243f788b..cf1a18e3 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -230,8 +230,8 @@ new_hash = { defcon: 3, action: true }
new_hash.keys #=> [:defcon, :action]
# Check existence of keys and values in hash
-new_hash.has_key?(:defcon) #=> true
-new_hash.has_value?(3) #=> true
+new_hash.key?(:defcon) #=> true
+new_hash.value?(3) #=> true
# Tip: Both Arrays and Hashes are Enumerable
# They share a lot of useful methods such as each, map, count, and more
diff --git a/sass.html.markdown b/sass.html.markdown
index 02bec47f..4d4ece71 100644
--- a/sass.html.markdown
+++ b/sass.html.markdown
@@ -4,40 +4,41 @@ filename: learnsass.scss
contributors:
- ["Laura Kyle", "https://github.com/LauraNK"]
- ["Sean Corrales", "https://github.com/droidenator"]
+ - ["Kyle Mendes", "https://github.com/pink401k"]
---
-Sass is a CSS extension language that adds features such as variables, nesting, mixins and more.
-Sass (and other preprocessors, such as [Less](http://lesscss.org/)) help developers to write maintainable and DRY (Don't Repeat Yourself) code.
+Sass is a CSS extension language that adds features such as variables, nesting, mixins and more.
+Sass (and other preprocessors, such as [Less](http://lesscss.org/)) help developers write maintainable and DRY (Don't Repeat Yourself) code.
-Sass has two different syntax options to choose from. SCSS, which has the same syntax as CSS but with the added features of Sass. Or Sass (the original syntax), which uses indentation rather than curly braces and semicolons.
+Sass has two different syntax options to choose from. SCSS, which has the same syntax as CSS but with the added features of Sass. Or Sass (the original syntax), which uses indentation rather than curly braces and semicolons.
This tutorial is written using SCSS.
-If you're already familiar with CSS3, you'll be able to pick up Sass relatively quickly. It does not provide any new styling options but rather the tools to write your CSS more efficiently and make maintenance much easier.
+If you're already familiar with CSS3, you'll be able to pick up Sass relatively quickly. It does not provide any new styling properties but rather the tools to write your CSS more efficiently and make maintenance much easier.
```scss
-
+
//Single line comments are removed when Sass is compiled to CSS.
-/*Multi line comments are preserved. */
-
-
-
-/*Variables
-==============================*/
-
-
+/* Multi line comments are preserved. */
+
+
+
+/* Variables
+============================== */
+
+
/* You can store a CSS value (such as a color) in a variable.
Use the '$' symbol to create a variable. */
-
+
$primary-color: #A3A4FF;
$secondary-color: #51527F;
-$body-font: 'Roboto', sans-serif;
+$body-font: 'Roboto', sans-serif;
+
+/* You can use the variables throughout your stylesheet.
+Now if you want to change a color, you only have to make the change once. */
-/* You can use the variables throughout your stylesheet.
-Now if you want to change a color, you only have to make the change once.*/
-
body {
background-color: $primary-color;
color: $secondary-color;
@@ -54,18 +55,18 @@ body {
/* This is much more maintainable than having to change the color
each time it appears throughout your stylesheet. */
-
-/*Mixins
-==============================*/
+
+/* Mixins
+============================== */
/* If you find you are writing the same code for more than one
element, you might want to store that code in a mixin.
-Use the '@mixin' directive, plus a name for your mixin.*/
+Use the '@mixin' directive, plus a name for your mixin. */
@mixin center {
display: block;
@@ -82,7 +83,7 @@ div {
background-color: $primary-color;
}
-/*Which would compile to: */
+/* Which would compile to: */
div {
display: block;
margin-left: auto;
@@ -99,8 +100,8 @@ div {
width: $width;
height: $height;
}
-
-/*Which you can invoke by passing width and height arguments. */
+
+/* Which you can invoke by passing width and height arguments. */
.rectangle {
@include size(100px, 60px);
@@ -110,31 +111,31 @@ div {
@include size(40px, 40px);
}
-/* This compiles to: */
+/* Compiles to: */
.rectangle {
width: 100px;
- height: 60px;
+ height: 60px;
}
.square {
width: 40px;
- height: 40px;
+ height: 40px;
}
-/*Functions
-==============================*/
-
-
-
-/* Sass provides functions that can be used to accomplish a variety of
+/* Functions
+============================== */
+
+
+
+/* Sass provides functions that can be used to accomplish a variety of
tasks. Consider the following */
-/* Functions can be invoked by using their name and passing in the
+/* Functions can be invoked by using their name and passing in the
required arguments */
body {
- width: round(10.25px);
+ width: round(10.25px);
}
.footer {
@@ -149,18 +150,18 @@ body {
.footer {
background-color: rgba(0, 0, 0, 0.75);
-}
-
-/* You may also define your own functions. Functions are very similar to
+}
+
+/* You may also define your own functions. Functions are very similar to
mixins. When trying to choose between a function or a mixin, remember
- that mixins are best for generating CSS while functions are better for
- logic that might be used throughout your Sass code. The examples in
- the Math Operators' section are ideal candidates for becoming a reusable
+ that mixins are best for generating CSS while functions are better for
+ logic that might be used throughout your Sass code. The examples in
+ the Math Operators' section are ideal candidates for becoming a reusable
function. */
-/* This function will take a target size and the parent size and calculate
+/* This function will take a target size and the parent size and calculate
and return the percentage */
-
+
@function calculate-percentage($target-size, $parent-size) {
@return $target-size / $parent-size * 100%;
}
@@ -187,12 +188,12 @@ $main-content: calculate-percentage(600px, 960px);
-/*Extend (Inheritance)
-==============================*/
+/* Extend (Inheritance)
+============================== */
-/*Extend is a way to share the properties of one selector with another. */
+/* Extend is a way to share the properties of one selector with another. */
.display {
@include size(5em, 5em);
@@ -208,36 +209,36 @@ $main-content: calculate-percentage(600px, 960px);
.display, .display-success {
width: 5em;
height: 5em;
- border: 5px solid #51527F;
+ border: 5px solid #51527F;
}
.display-success {
- border-color: #22df56;
+ border-color: #22df56;
}
-/* Extending a CSS statement is preferable to creating a mixin
- because of the way it groups together the classes that all share
- the same base styling. If this was done with a mixin, the width,
- height, and border would be duplicated for each statement that
+/* Extending a CSS statement is preferable to creating a mixin
+ because of the way Sass groups together the classes that all share
+ the same base styling. If this was done with a mixin, the width,
+ height, and border would be duplicated for each statement that
called the mixin. While it won't affect your workflow, it will
add unnecessary bloat to the files created by the Sass compiler. */
-
-/*Nesting
-==============================*/
+
+/* Nesting
+============================== */
-/*Sass allows you to nest selectors within selectors */
+/* Sass allows you to nest selectors within selectors */
ul {
list-style-type: none;
margin-top: 2em;
-
+
li {
- background-color: #FF0000;
- }
+ background-color: #FF0000;
+ }
}
/* '&' will be replaced by the parent selector. */
@@ -249,18 +250,18 @@ For example: */
ul {
list-style-type: none;
margin-top: 2em;
-
+
li {
background-color: red;
-
+
&:hover {
background-color: blue;
}
-
+
a {
color: white;
}
- }
+ }
}
/* Compiles to: */
@@ -284,17 +285,17 @@ ul li a {
-/*Partials and Imports
-==============================*/
-
-
-
+/* Partials and Imports
+============================== */
+
+
+
/* Sass allows you to create partial files. This can help keep your Sass
code modularized. Partial files should begin with an '_', e.g. _reset.css.
Partials are not generated into CSS. */
-
+
/* Consider the following CSS which we'll put in a file called _reset.css */
-
+
html,
body,
ul,
@@ -302,14 +303,14 @@ ol {
margin: 0;
padding: 0;
}
-
+
/* Sass offers @import which can be used to import partials into a file.
- This differs from the traditional CSS @import statement which makes
- another HTTP request to fetch the imported file. Sass takes the
+ This differs from the traditional CSS @import statement which makes
+ another HTTP request to fetch the imported file. Sass takes the
imported file and combines it with the compiled code. */
-
+
@import 'reset';
-
+
body {
font-size: 16px;
font-family: Helvetica, Arial, Sans-serif;
@@ -320,25 +321,25 @@ body {
html, body, ul, ol {
margin: 0;
padding: 0;
-}
+}
body {
font-size: 16px;
font-family: Helvetica, Arial, Sans-serif;
}
-
-
-/*Placeholder Selectors
-==============================*/
-
-
-
+
+
+/* Placeholder Selectors
+============================== */
+
+
+
/* Placeholders are useful when creating a CSS statement to extend. If you
wanted to create a CSS statement that was exclusively used with @extend,
you can do so using a placeholder. Placeholders begin with a '%' instead
of '.' or '#'. Placeholders will not appear in the compiled CSS. */
-
+
%content-window {
font-size: 14px;
padding: 10px;
@@ -364,18 +365,18 @@ body {
background-color: #0000ff;
}
-
-
-/*Math Operations
-==============================*/
-
-
-
+
+
+/* Math Operations
+============================== */
+
+
+
/* Sass provides the following operators: +, -, *, /, and %. These can
be useful for calculating values directly in your Sass files instead
of using values that you've already calculated by hand. Below is an example
of a setting up a simple two column design. */
-
+
$content-area: 960px;
$main-content: 600px;
$sidebar-content: 300px;
@@ -418,14 +419,11 @@ body {
width: 6.25%;
}
-
-```
-
-
+```
## SASS or Sass?
-Have you ever wondered whether Sass is an acronym or not? You probably haven't, but I'll tell you anyway. The name of the language is a word, "Sass", and not an acronym.
-Because people were constantly writing it as "SASS", the creator of the language jokingly called it "Syntactically Awesome StyleSheets".
+Have you ever wondered whether Sass is an acronym or not? You probably haven't, but I'll tell you anyway. The name of the language is a word, "Sass", and not an acronym.
+Because people were constantly writing it as "SASS", the creator of the language jokingly called it "Syntactically Awesome StyleSheets".
## Practice Sass
@@ -434,14 +432,13 @@ You can use either syntax, just go into the settings and select either Sass or S
## Compatibility
-
Sass can be used in any project as long as you have a program to compile it
into CSS. You'll want to verify that the CSS you're using is compatible
-with your target browsers.
+with your target browsers.
+
+[QuirksMode CSS](http://www.quirksmode.org/css/) and [CanIUse](http://caniuse.com) are great resources for checking compatibility.
-[QuirksMode CSS](http://www.quirksmode.org/css/) and [CanIUse](http://caniuse.com) are great resources for checking compatibility.
-
## Further reading
* [Official Documentation](http://sass-lang.com/documentation/file.SASS_REFERENCE.html)
* [The Sass Way](http://thesassway.com/) provides tutorials (beginner-advanced) and articles.
diff --git a/tr-tr/python3-tr.html.markdown b/tr-tr/python3-tr.html.markdown
index 2477c5da..c7de2922 100644
--- a/tr-tr/python3-tr.html.markdown
+++ b/tr-tr/python3-tr.html.markdown
@@ -538,7 +538,7 @@ Insan.grunt() # => "*grunt*"
# Modülleri içe aktarabilirsiniz
import math
-print(math.sqrt(16)) # => 4
+print(math.sqrt(16)) # => 4.0
# Modülden belirli bir fonksiyonları alabilirsiniz
from math import ceil, floor
diff --git a/zh-cn/python3-cn.html.markdown b/zh-cn/python3-cn.html.markdown
index c223297c..76455a46 100644
--- a/zh-cn/python3-cn.html.markdown
+++ b/zh-cn/python3-cn.html.markdown
@@ -535,7 +535,7 @@ Human.grunt() # => "*grunt*"
# 用import导入模块
import math
-print(math.sqrt(16)) # => 4
+print(math.sqrt(16)) # => 4.0
# 也可以从模块中导入个别值
from math import ceil, floor