diff options
| -rw-r--r-- | c++.html.markdown | 80 | ||||
| -rw-r--r-- | css.html.markdown | 12 | ||||
| -rw-r--r-- | es-es/julia-es.html.markdown | 14 | ||||
| -rw-r--r-- | id-id/json-id.html.markdown | 60 | ||||
| -rw-r--r-- | id-id/xml-id.html.markdown | 129 | ||||
| -rw-r--r-- | javascript.html.markdown | 3 | ||||
| -rw-r--r-- | php.html.markdown | 4 | ||||
| -rw-r--r-- | pt-br/c++-pt.html.markdown | 2 | ||||
| -rw-r--r-- | python.html.markdown | 2 | 
9 files changed, 252 insertions, 54 deletions
| diff --git a/c++.html.markdown b/c++.html.markdown index 26dfe111..4acc1b9d 100644 --- a/c++.html.markdown +++ b/c++.html.markdown @@ -5,6 +5,7 @@ contributors:      - ["Steven Basart", "http://github.com/xksteven"]      - ["Matt Kline", "https://github.com/mrkline"]      - ["Geoff Liu", "http://geoffliu.me"] +    - ["Connor Waters", "http://github.com/connorwaters"]  lang: en  --- @@ -53,11 +54,11 @@ int main(int argc, char** argv)  // However, C++ varies in some of the following ways: -// In C++, character literals are one byte. -sizeof('c') == 1 +// In C++, character literals are chars +sizeof('c') == sizeof(char) == 1 -// In C, character literals are the same size as ints. -sizeof('c') == sizeof(10) +// In C, character literals are ints +sizeof('c') == sizeof(int)  // C++ has strict prototyping @@ -159,9 +160,9 @@ void foo()  int main()  { -    // Includes all symbols from `namesapce Second` into the current scope. Note -    // that simply `foo()` no longer works, since it is now ambiguous whether -    // we're calling the `foo` in `namespace Second` or the top level. +    // Includes all symbols from namespace Second into the current scope. Note +    // that simply foo() no longer works, since it is now ambiguous whether +    // we're calling the foo in namespace Second or the top level.      using namespace Second;      Second::foo(); // prints "This is Second::foo" @@ -256,7 +257,7 @@ string tempObjectFun() { ... }  string retVal = tempObjectFun();  // What happens in the second line is actually: -//   - a string object is returned from `tempObjectFun` +//   - a string object is returned from tempObjectFun  //   - a new string is constructed with the returned object as arugment to the  //     constructor  //   - the returned object is destroyed @@ -268,15 +269,15 @@ string retVal = tempObjectFun();  // code:  foo(bar(tempObjectFun())) -// assuming `foo` and `bar` exist, the object returned from `tempObjectFun` is -// passed to `bar`, and it is destroyed before `foo` is called. +// assuming foo and bar exist, the object returned from tempObjectFun is +// passed to bar, and it is destroyed before foo is called.  // Now back to references. The exception to the "at the end of the enclosing  // expression" rule is if a temporary object is bound to a const reference, in  // which case its life gets extended to the current scope:  void constReferenceTempObjectFun() { -  // `constRef` gets the temporary object, and it is valid until the end of this +  // constRef gets the temporary object, and it is valid until the end of this    // function.    const string& constRef = tempObjectFun();    ... @@ -301,7 +302,7 @@ basic_string(basic_string&& other);  // Idea being if we are constructing a new string from a temporary object (which  // is going to be destroyed soon anyway), we can have a more efficient  // constructor that "salvages" parts of that temporary string. You will see this -// concept referred to as the move semantic. +// concept referred to as "move semantics".  //////////////////////////////////////////  // Classes and object-oriented programming @@ -349,7 +350,10 @@ public:      // These are called when an object is deleted or falls out of scope.      // This enables powerful paradigms such as RAII      // (see below) -    // Destructors must be virtual to allow classes to be derived from this one. +    // The destructor should be virtual if a class is to be derived from; +    // if it is not virtual, then the derived class' destructor will +    // not be called if the object is destroyed through a base-class reference +    // or pointer.      virtual ~Dog();  }; // A semicolon must follow the class definition. @@ -492,9 +496,10 @@ int main () {  /////////////////////  // Templates in C++ are mostly used for generic programming, though they are -// much more powerful than generics constructs in other languages. It also -// supports explicit and partial specialization, functional-style type classes, -// and also it's Turing-complete. +// much more powerful than generic constructs in other languages. They also +// support explicit and partial specialization and functional-style type +// classes; in fact, they are a Turing-complete functional language embedded +// in C++!  // We start with the kind of generic programming you might be familiar with. To  // define a class or function that takes a type parameter: @@ -506,7 +511,7 @@ public:  };  // During compilation, the compiler actually generates copies of each template -// with parameters substituted, and so the full definition of the class must be +// with parameters substituted, so the full definition of the class must be  // present at each invocation. This is why you will see template classes defined  // entirely in header files. @@ -520,13 +525,13 @@ intBox.insert(123);  Box<Box<int> > boxOfBox;  boxOfBox.insert(intBox); -// Up until C++11, you must place a space between the two '>'s, otherwise '>>' -// will be parsed as the right shift operator. +// Until C++11, you had to place a space between the two '>'s, otherwise '>>' +// would be parsed as the right shift operator.  // You will sometimes see  //   template<typename T> -// instead. The 'class' keyword and 'typename' keyword are _mostly_ -// interchangeable in this case. For full explanation, see +// instead. The 'class' keyword and 'typename' keywords are _mostly_ +// interchangeable in this case. For the full explanation, see  //   http://en.wikipedia.org/wiki/Typename  // (yes, that keyword has its own Wikipedia page). @@ -582,12 +587,15 @@ try {      // Do not allocate exceptions on the heap using _new_.      throw std::runtime_error("A problem occurred");  } +  // Catch exceptions by const reference if they are objects  catch (const std::exception& ex)  { -  std::cout << ex.what(); +    std::cout << ex.what(); +} +  // Catches any exception not caught by previous _catch_ blocks -} catch (...) +catch (...)  {      std::cout << "Unknown exception caught";      throw; // Re-throws the exception @@ -597,8 +605,8 @@ catch (const std::exception& ex)  // RAII  /////// -// RAII stands for Resource Allocation Is Initialization. -// It is often considered the most powerful paradigm in C++, +// RAII stands for "Resource Acquisition Is Initialization". +// It is often considered the most powerful paradigm in C++  // and is the simple concept that a constructor for an object  // acquires that object's resources and the destructor releases them. @@ -619,9 +627,9 @@ void doSomethingWithAFile(const char* filename)  // Unfortunately, things are quickly complicated by error handling.  // Suppose fopen can fail, and that doSomethingWithTheFile and  // doSomethingElseWithIt return error codes if they fail. -// (Exceptions are the preferred way of handling failure, -//  but some programmers, especially those with a C background, -//  disagree on the utility of exceptions). +//  (Exceptions are the preferred way of handling failure, +//   but some programmers, especially those with a C background, +//   disagree on the utility of exceptions).  // We now have to check each call for failure and close the file handle  // if a problem occurred.  bool doSomethingWithAFile(const char* filename) @@ -735,21 +743,23 @@ class Foo {    virtual void bar();  };  class FooSub : public Foo { -  virtual void bar();  // overrides Foo::bar! +  virtual void bar();  // Overrides Foo::bar!  };  // 0 == false == NULL (most of the time)!  bool* pt = new bool; -*pt = 0;  // Sets the value points by 'pt' to false. +*pt = 0; // Sets the value points by 'pt' to false.  pt = 0;  // Sets 'pt' to the null pointer. Both lines compile without warnings.  // nullptr is supposed to fix some of that issue:  int* pt2 = new int; -*pt2 = nullptr;  // Doesn't compile +*pt2 = nullptr; // Doesn't compile  pt2 = nullptr;  // Sets pt2 to null. -// But somehow 'bool' type is an exception (this is to make `if (ptr)` compile). +// There is an exception made for bools. +// This is to allow you to test for null pointers with if(!ptr), +// but as a consequence you can assign nullptr to a bool directly!  *pt = nullptr;  // This still compiles, even though '*pt' is a bool! @@ -776,12 +786,12 @@ vector<Foo> v;  for (int i = 0; i < 10; ++i)    v.push_back(Foo()); -// Following line sets size of v to 0, but destructors don't get called, +// Following line sets size of v to 0, but destructors don't get called  // and resources aren't released!  v.empty(); -v.push_back(Foo());  // New value is copied into the first Foo we inserted in the loop. +v.push_back(Foo());  // New value is copied into the first Foo we inserted -// Truly destroys all values in v. See section about temporary object for +// Truly destroys all values in v. See section about temporary objects for  // explanation of why this works.  v.swap(vector<Foo>()); diff --git a/css.html.markdown b/css.html.markdown index 9e8664b3..7224d80a 100644 --- a/css.html.markdown +++ b/css.html.markdown @@ -7,19 +7,19 @@ contributors:  filename: learncss.css  --- -In early days of web there was no visual elements, just pure text. But with the   -further development of browser fully visual web pages also became common.    +In the early days of the web there were no visual elements, just pure text. But with the   +further development of browsers, fully visual web pages also became common.     CSS is the standard language that exists to keep the separation between     the content (HTML) and the look-and-feel of web pages.  In short, what CSS does is to provide a syntax that enables you to target     different elements on an HTML page and assign different visual properties to them. -Like any other language, CSS has many versions. Here we focus on CSS2.0    -which is not the most recent but the most widely supported and compatible version. +Like any other languages, CSS has many versions. Here we focus on CSS2.0,    +which is not the most recent version, but is the most widely supported and compatible version. -**NOTE:** Because the outcome of CSS is some visual effects, in order to  -learn it, you need try all different things in a  +**NOTE:** Because the outcome of CSS consists of visual effects, in order to  +learn it, you need try everything in a   CSS playground like [dabblet](http://dabblet.com/).  The main focus of this article is on the syntax and some general tips. diff --git a/es-es/julia-es.html.markdown b/es-es/julia-es.html.markdown index 95a16412..e4181609 100644 --- a/es-es/julia-es.html.markdown +++ b/es-es/julia-es.html.markdown @@ -45,7 +45,7 @@ Esto se basa en la versión `0.3.11`.  # Los comentarios de una línea comienzan con una almohadilla (o signo de gato).  #= -  Los commentarios multilínea pueden escribirse +  Los comentarios multilínea pueden escribirse    usando '#=' antes de el texto  y '=#'    después del texto. También se pueden anidar.  =# @@ -174,7 +174,7 @@ otraVariable_123! = 6    # => 6      otra_variable    * Los nombres de los tipos comienzan con una letra mayúscula y separación de -    palabras se muestra con CamelCase en vez de guion bajo: +    palabras se muestra con CamelCase en vez de guión bajo:      OtroTipo @@ -214,7 +214,7 @@ matrix = [1 2; 3 4]       3  4  =# -# Añadir cosas a la final de un arreglo con push! y append!. +# Añadir cosas al final de un arreglo con push! y append!.  push!(a, 1)      # => [1]  push!(a, 2)      # => [1,2]  push!(a, 4)      # => [1,2,4] @@ -237,7 +237,7 @@ a[end]    # => 6  shift!(a)         # => 1 y a es ahora: [2,4,3,4,5,6]  unshift!(a, 7)    # => [7,2,4,3,4,5,6] -# Los nombres de funciónes que terminan en exclamaciones indican que modifican +# Los nombres de funciones que terminan en exclamaciones indican que modifican  # su o sus argumentos de entrada.  arr = [5, 4, 6]    # => 3-element Array{Int64,1}: [5,4,6]  sort(arr)          # => [4,5,6] y arr es todavía: [5,4,6] @@ -710,7 +710,7 @@ end  # Sólo define una función del mismo nombre que el tipo y llama al constructor  # existente para obtener un valor del tipo correcto. -# Este es un constructor externo porque es fuera de la definición del tipo. +# Este es un constructor externo porque está fuera de la definición del tipo.  Leon(rugido::String) = Leon("verde", rugido)  type Pantera <: Gato    # Pantera también es un a subtipo de Gato @@ -730,10 +730,10 @@ end  ########################  # En Julia, todas las funciones nombradas son funciones genéricas. -# Esto significa que se construyen a partir de muchos métodosmás pequeños. +# Esto significa que se construyen a partir de muchos métodos más pequeños.  # Cada constructor de Leon es un método de la función genérica Leon. -# Por ejemplo, vamos a hacer métodos para para Leon, Pantera, y Tigre de una +# Por ejemplo, vamos a hacer métodos para Leon, Pantera, y Tigre de una  # función genérica maullar:  # acceso utilizando notación de puntos diff --git a/id-id/json-id.html.markdown b/id-id/json-id.html.markdown new file mode 100644 index 00000000..52e61449 --- /dev/null +++ b/id-id/json-id.html.markdown @@ -0,0 +1,60 @@ +--- +language: json +filename: learnjson.json +contributors: +  - ["Anna Harren", "https://github.com/iirelu"] +  - ["Marco Scannadinari", "https://github.com/marcoms"] +translators +  - ["Rizky Luthfianto", "https://github.com/rilut"] +--- + +JSON adalah format pertukaran data yang sangat simpel, kemungkinan besar, +ini adalah "Learn X in Y Minutes" yang paling singkat. + +Murninya, JSON tidak mempunyai fitur komentar, tapi kebanyakan parser akan +menerima komentar bergaya bahasa C (`//`, `/* */`). Namun, pada halaman ini, +hanya dicontohkan JSON yang 100% valid. + +```json +{ +  "kunci": "nilai", +   +  "kunci": "harus selalu diapit tanda kutip", +  "angka": 0, +  "strings": "Halø, dunia. Semua karaktor unicode diperbolehkan, terumasuk \"escaping\".", +  "punya tipe data boolean?": true, +  "nilai kosong": null, + +  "angka besar": 1.2e+100, + +  "obyek": { +    "komentar": "Most of your structure will come from objects.", + +    "array": [0, 1, 2, 3, "Array bisa berisi apapun.", 5], + +    "obyek lainnya": { +      "komentar": "Obyek-obyek JSON dapat dibuat bersarang, sangat berguna." +    } +  }, + +  "iseng-iseng": [ +    { +      "sumber potassium": ["pisang"] +    }, +    [ +      [1, 0, 0, 0], +      [0, 1, 0, 0], +      [0, 0, 1, "neo"], +      [0, 0, 0, 1] +    ] +  ], +   +  "gaya alternatif": { +    "komentar": "lihat ini!" +  , "posisi tanda koma": "tak masalah. selama sebelum nilai berikutnya, valid-valid saja" +  , "komentar lainnya": "betapa asyiknya" +  }, + +  "singkat": "Dan Anda selesai! Sekarang Anda tahu apa saja yang disediakan oleh JSON." +} +``` diff --git a/id-id/xml-id.html.markdown b/id-id/xml-id.html.markdown new file mode 100644 index 00000000..8e8cdf4e --- /dev/null +++ b/id-id/xml-id.html.markdown @@ -0,0 +1,129 @@ +--- +language: xml +filename: learnxml.xml +contributors: +  - ["João Farias", "https://github.com/JoaoGFarias"] +translators: +  - ["Rizky Luthfianto", "https://github.com/rilut"] +--- + +XML adalah bahasa markup yang dirancang untuk menyimpan dan mengirim data. + +Tidak seperti HTML, XML tidak menentukan bagaimana menampilkan atau format data, hanya membawanya. + +* Sintaks XML + +```xml +<!-- Komentar di XML seperti ini --> + +<?xml version="1.0" encoding="UTF-8"?> +<tokobuku> +  <buku category="MEMASAK"> +    <judul lang="en">Everyday Italian</judul> +    <pengarang>Giada De Laurentiis</pengarang> +    <tahun>2005</tahun> +    <harga>30.00</harga> +  </buku> +  <buku category="ANAK"> +    <judul lang="en">Harry Potter</judul> +    <pengarang>J K. Rowling</pengarang> +    <tahun>2005</tahun> +    <harga>29.99</harga> +  </buku> +  <buku category="WEB"> +    <judul lang="en">Learning XML</judul> +    <pengarang>Erik T. Ray</pengarang> +    <tahun>2003</tahun> +    <harga>39.95</harga> +  </buku> +</tokobuku> + +<!-- Di atas adalah contoh file XML biasa. +   Dimulai dengan deklarasi, menginformasikan beberapa metadata (opsional). +   +   XML menggunakan struktur pohon. Di atas, simpul akar adalah 'tokobuku', +   yang memiliki tiga node anak, para 'buku'. Node-node tersebut dapat memiliki +   node-node anak, dan seterusnya ... +   +   Node dibuat menggunakan tag buka/tutup, dan node-node anak hanya +   berada di antara tag buka dan tutup .--> + + +<!-- XML membawa dua jenis data: +   1 - Atribut -> Itu metadata tentang sebuah node. +       Biasanya, parser XML menggunakan informasi ini untuk menyimpan data dengan +       benar. Hal ini ditandai dengan muncul dengan format nama = "nilai" dalam pembukaan tag. +   2 - Elemen -> Itu data yang murni. +       Itulah yang parser akan mengambil dari file XML. +       Elemen muncul antara tag membuka dan menutup.--> +       +   +<!-- Di bawah ini, unsur dengan dua atribut--> +<file type="gif" id="4293">komputer.gif</file> + + +``` + +* Dokumen yang well-formated & Validasi + +Sebuah dokumen XML disebut well-formated jika sintaksisnya benar. +Namun, juga mungkin untuk mendefinisikan lebih banyak batasan dalam dokumen, +menggunakan definisi dokumen, seperti DTD dan XML Schema. + +Sebuah dokumen XML yang mengikuti definisi dokumen disebut valid, +jika sesuai dokumen itu. + +Dengan alat ini, Anda dapat memeriksa data XML di luar logika aplikasi. + +```xml + +<!-- Di bawah, Anda dapat melihat versi sederhana dari dokumen tokobuku, +  dengan penambahan definisi DTD .--> + +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE catatan SYSTEM "tokobuku.dtd"> +<tokobuku> +  <buku category="MEMASAK"> +    <judul >Everyday Italian</judul> +    <harga>30.00</harga> +  </buku> +</tokobuku> + +<!-- This DTD could be something like:--> + +<!DOCTYPE catatan +[ +<!ELEMENT tokobuku (buku+)> +<!ELEMENT buku (judul,harga)> +<!ATTLIST buku category CDATA "Sastra"> +<!ELEMENT judul (#PCDATA)> +<!ELEMENT harga (#PCDATA)> +]> + + +<!-- DTD dimulai dengan deklarasi. +  Berikut, node akar dinyatakan, membutuhkan 1 atau lebih anak node 'buku'. +  Setiap 'buku' harus berisi tepat satu 'judul' dan 'harga' dan atribut +  disebut 'kategori', dengan "Sastra" sebagai nilai default. +  Node yang 'judul' dan 'harga' mengandung karakter data diurai .--> + +<!-- DTD dapat dideklarasikan di dalam file XML itu sendiri .--> + +<?xml version="1.0" encoding="UTF-8"?> + +<!DOCTYPE catatan +[ +<!ELEMENT tokobuku (buku+)> +<!ELEMENT buku (judul,harga)> +<!ATTLIST buku category CDATA "Sastra"> +<!ELEMENT judul (#PCDATA)> +<!ELEMENT harga (#PCDATA)> +]> + +<tokobuku> +  <buku category="MEMASAK"> +    <judul >Everyday Italian</judul> +    <harga>30.00</harga> +  </buku> +</tokobuku> +``` diff --git a/javascript.html.markdown b/javascript.html.markdown index 588ea86d..ba2e8ce4 100644 --- a/javascript.html.markdown +++ b/javascript.html.markdown @@ -475,9 +475,6 @@ myNumber === myNumberObj; // = false  if (0){      // This code won't execute, because 0 is falsy.  } -if (Number(0)){ -    // This code *will* execute, because Number(0) is truthy. -}  // However, the wrapper objects and the regular builtins share a prototype, so  // you can actually add functionality to a string, for instance. diff --git a/php.html.markdown b/php.html.markdown index 2d4565e0..3fcce264 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -487,7 +487,7 @@ class MyClass   * Declaring class properties or methods as static makes them accessible without   * needing an instantiation of the class. A property declared as static can not   * be accessed with an instantiated class object (though a static method can). -*/ + */      public static function myStaticMethod()      { @@ -495,7 +495,9 @@ class MyClass      }  } +// Class constants can always be accessed statically   echo MyClass::MY_CONST;    // Outputs 'value'; +  echo MyClass::$staticVar;  // Outputs 'static';  MyClass::myStaticMethod(); // Outputs 'I am static'; diff --git a/pt-br/c++-pt.html.markdown b/pt-br/c++-pt.html.markdown index 61625ebe..61e267f5 100644 --- a/pt-br/c++-pt.html.markdown +++ b/pt-br/c++-pt.html.markdown @@ -304,7 +304,7 @@ void Dog::Dog()  }  // Objetos (como strings) devem ser passados por referência -// se você está modificando-os ou referência const se você não é. +// se você pretende modificá-los, ou com const caso contrário.  void Dog::setName(const std::string& dogsName)  {      name = dogsName; diff --git a/python.html.markdown b/python.html.markdown index 352f7349..5572e38e 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -198,7 +198,7 @@ li[::-1]   # => [3, 4, 2, 1]  # Remove arbitrary elements from a list with "del"  del li[2]   # li is now [1, 2, 3] -r +  # You can add lists  li + other_li   # => [1, 2, 3, 4, 5, 6]  # Note: values for li and for other_li are not modified. | 
