From af29a504c0eb02e9eb575d5cace38676f7cf1ef1 Mon Sep 17 00:00:00 2001 From: Bonnie Barrilleaux Date: Wed, 5 Nov 2014 14:06:34 -0800 Subject: Added a few clarifying lines to Scala so that the examples can be run as given. Removed a duplicate example. --- scala.html.markdown | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scala.html.markdown b/scala.html.markdown index 5a0cc0ff..201a51ab 100644 --- a/scala.html.markdown +++ b/scala.html.markdown @@ -189,6 +189,8 @@ sSquared.reduce (_+_) // The filter function takes a predicate (a function from A -> Boolean) and // selects all elements which satisfy the predicate List(1, 2, 3) filter (_ > 2) // List(3) + +case class Person(name: String, age: Int) List( Person(name = "Dom", age = 23), Person(name = "Bob", age = 30) @@ -197,6 +199,7 @@ List( // Scala a foreach method defined on certain collections that takes a type // returning Unit (a void method) +val aListOfNumbers = Set(1,2,3,45,234) aListOfNumbers foreach (x => println(x)) aListOfNumbers foreach println @@ -255,6 +258,7 @@ def showNumbersInRange(a:Int, b:Int):Unit = { if (a < b) showNumbersInRange(a + 1, b) } +showNumbersInRange(1,14) @@ -270,15 +274,13 @@ if (x == 11) println ("yeah") else println("nay") println(if (x == 10) "yeah" else "nope") val text = if (x == 10) "yeah" else "nope" -var i = 0 -while (i < 10) { println("i " + i); i+=1 } - // Object oriented features // Classname is Dog -class Dog { +class Dog (br: String) { + var breed: String = br //A method called bark, returning a String def bark: String = { // the body of the method @@ -286,6 +288,11 @@ class Dog { } } +val mydog = new Dog("greyhound") +println(mydog.breed) // => "greyhound" +println(mydog.bark) // => "Woof, woof!" + + // Classes can contain nearly any other construct, including other classes, // functions, methods, objects, case classes, traits etc. -- cgit v1.2.3 From e45b3f5bdbcbbb02fa304beafda8676a7227354c Mon Sep 17 00:00:00 2001 From: Adam Bard Date: Thu, 6 Nov 2014 16:09:45 +0200 Subject: Update python3-cn.html.markdown --- zh-cn/python3-cn.html.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zh-cn/python3-cn.html.markdown b/zh-cn/python3-cn.html.markdown index 1b3f5086..c223297c 100644 --- a/zh-cn/python3-cn.html.markdown +++ b/zh-cn/python3-cn.html.markdown @@ -6,7 +6,8 @@ contributors: - ["Andre Polykanine", "https://github.com/Oire"] translators: - ["Geoff Liu", "http://geoffliu.me"] -filename: learnpython3.py +filename: learnpython3-cn.py +lang: zh-cn --- Python是由吉多·范罗苏姆(Guido Van Rossum)在90年代早期设计。它是如今最常用的编程 -- cgit v1.2.3 From a32a8e140153d5ffd341bb38515660f80da37575 Mon Sep 17 00:00:00 2001 From: Bonnie Date: Thu, 6 Nov 2014 18:47:38 -0800 Subject: Remove an extraneous space. --- scala.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scala.html.markdown b/scala.html.markdown index 201a51ab..775956cb 100644 --- a/scala.html.markdown +++ b/scala.html.markdown @@ -279,7 +279,7 @@ val text = if (x == 10) "yeah" else "nope" // Object oriented features // Classname is Dog -class Dog (br: String) { +class Dog(br: String) { var breed: String = br //A method called bark, returning a String def bark: String = { -- cgit v1.2.3 From e3c13dd8ce6166b69e8085caea11da963d215d74 Mon Sep 17 00:00:00 2001 From: Peter Mortensen Date: Sun, 9 Nov 2014 10:25:00 +0100 Subject: Update README.markdown Copy edited (e.g. ref. , , , http://en.wikipedia.org/wiki/Python_%28programming_language%29, , and ). --- README.markdown | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index dc379a9b..4e24bbe6 100644 --- a/README.markdown +++ b/README.markdown @@ -14,12 +14,12 @@ properly! ## Contributing -All contributions welcome, from the tiniest typo to a brand new article. Translations +All contributions are welcome, from the tiniest typo to a brand new article. Translations in all languages are welcome (or, for that matter, original articles in any language). Send a pull request or open an issue any time of day or night. **Please tag your issues pull requests with [language/lang-code] at the beginning** -**(e.g. [python/en] for english python).** This will help everyone pick out things they +**(e.g. [python/en] for English Python).** This will help everyone pick out things they care about. ### Style Guidelines @@ -27,7 +27,7 @@ care about. * **Keep lines under 80 chars** * **Prefer example to exposition** * **Eschew surplusage** -* **Use utf-8** +* **Use UTF-8** Long version: @@ -38,28 +38,28 @@ Long version: * We welcome newcomers, but the target audience for this site is programmers with some experience. So, try to avoid explaining basic concepts except for those specific to the language in question, - to keep articles succinct and scannable. We all know how to use google here. + to keep articles succinct and scannable. We all know how to use Google here. -* For translations (or english articles with non-ASCII characters), please make sure your file is - utf-8 encoded, and try to leave out the byte-order-mark at the start of the file. (`:set nobomb` in vim) +* For translations (or English articles with non-ASCII characters), please make sure your file is + UTF-8 encoded, and try to leave out the byte-order-mark at the start of the file. (`:set nobomb` in Vim) ### Header configuration -The actual site uses Middleman to generate HTML files from these markdown ones. Middleman, or at least +The actual site uses Middleman to generate HTML files from these Markdown ones. Middleman, or at least the custom scripts underpinning the site, required that some key information be defined in the header. -The following fields are necessary for english articles about programming languages: +The following fields are necessary for English articles about programming languages: * **language** The *programming language* in question -* **contributors** A list of [author, url] lists to credit +* **contributors** A list of [author, URL] lists to credit Other fields: * **filename**: The filename for this article's code. It will be fetched, mashed together, and made downloadable. - For non-english articles, *filename* should have a language-specific suffix. + For non-English articles, *filename* should have a language-specific suffix. * **lang**: For translations, the human language this article is in. For categorization, mostly. -Here's an example header for an esperanto translation of Ruby: +Here's an example header for an Esperanto translation of Ruby: ```yaml --- -- cgit v1.2.3 From 9576d80b75a025740775b7a16ee327403df25e88 Mon Sep 17 00:00:00 2001 From: Kishore Relangi Date: Mon, 10 Nov 2014 15:50:47 +0530 Subject: Update perl6.html.markdown It is actually generating fibonacci series --- perl6.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl6.html.markdown b/perl6.html.markdown index 52625bc2..9f3a03ba 100644 --- a/perl6.html.markdown +++ b/perl6.html.markdown @@ -1149,7 +1149,7 @@ my @list = 1, 3, 9 ... * > 30; # you can use a predicate # (with the Whatever Star, here). my @list = 1, 3, 9 ... { $_ > 30 }; # (equivalent to the above) -my @fib = 1, 1, *+* ... *; # lazy infinite list of prime numbers, +my @fib = 1, 1, *+* ... *; # lazy infinite list of fibonacci series, # computed using a closure! my @fib = 1, 1, -> $a, $b { $a + $b } ... *; # (equivalent to the above) my @fib = 1, 1, { $^a + $^b } ... *; #(... also equivalent to the above) -- cgit v1.2.3 From 9ddc2d0a5b92974ac1614024b4586354a395482e Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Mon, 10 Nov 2014 19:45:17 -0600 Subject: Add Ruby exceptions. --- ruby.html.markdown | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ruby.html.markdown b/ruby.html.markdown index 3c67de2e..a1a2c77b 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -10,6 +10,7 @@ contributors: - ["Marcos Brizeno", "http://www.about.me/marcosbrizeno"] - ["Ariel Krakowski", "http://www.learneroo.com"] - ["Dzianis Dashkevich", "https://github.com/dskecse"] + - ["Levi Bostian", "https://github.com/levibostian"] --- @@ -271,6 +272,19 @@ else end #=> "OK job" +# exception handling +begin + # code here that might raise an exception + raise NoMemoryError, 'You ran out of memory.' +rescue NoMemoryError => exception_variable + puts 'NoMemoryError was raised', exception_variable +rescue RuntimeError => other_exception_variable + puts 'RuntimeError was raised now' +else + puts 'This runs if no exceptions were thrown at all' +ensure + puts 'This code always runs no matter what' +end # Functions -- cgit v1.2.3 From 0698ed27c1c63100fabf01be654a412186982042 Mon Sep 17 00:00:00 2001 From: Jack Hooper Date: Wed, 12 Nov 2014 00:28:03 +1100 Subject: There's no apostrophe in 90s Apostrophes are for indicating an abbreviation or for denoting possession. '90s' is merely a plural. It is an abbreviation of 1990s, so technically it ought to be '90s, but for all intents and purposes this is optional. --- python.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python.html.markdown b/python.html.markdown index ba236fb3..411194f4 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -7,7 +7,7 @@ contributors: filename: learnpython.py --- -Python was created by Guido Van Rossum in the early 90's. It is now one of the most popular +Python was created by Guido Van Rossum in the early 90s. It is now one of the most popular languages in existence. I fell in love with Python for its syntactic clarity. It's basically executable pseudocode. -- cgit v1.2.3 From 0429c31d6d640889cd40ad0fba89a476bf1e7480 Mon Sep 17 00:00:00 2001 From: Jack Hooper Date: Wed, 12 Nov 2014 00:30:19 +1100 Subject: Updated note regarding Python 3 tutorial. --- python.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python.html.markdown b/python.html.markdown index 411194f4..961d0965 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -14,7 +14,7 @@ executable pseudocode. Feedback would be highly appreciated! You can reach me at [@louiedinh](http://twitter.com/louiedinh) or louiedinh [at] [google's email service] Note: This article applies to Python 2.7 specifically, but should be applicable -to Python 2.x. Look for another tour of Python 3 soon! +to Python 2.x. For Python 3.x, take a look at the Python 3 tutorial. ```python -- cgit v1.2.3 From 4d85f161d8399f80e3c7ca93eb7ad8ed8018a327 Mon Sep 17 00:00:00 2001 From: Jack Hooper Date: Wed, 12 Nov 2014 02:03:50 +1100 Subject: More apostrophe fixes I hate to be that guy, but... I found a couple more. --- python.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python.html.markdown b/python.html.markdown index 961d0965..f7b0082c 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -21,7 +21,7 @@ to Python 2.x. For Python 3.x, take a look at the Python 3 tutorial. # Single line comments start with a number symbol. """ Multiline strings can be written - using three "'s, and are often used + using three "s, and are often used as comments """ @@ -55,7 +55,7 @@ to Python 2.x. For Python 3.x, take a look at the Python 3 tutorial. # Modulo operation 7 % 3 # => 1 -# Exponentiation (x to the y'th power) +# Exponentiation (x to the yth power) 2**4 # => 16 # Enforce precedence with parentheses -- cgit v1.2.3 From 38cf765079a3bd7ea8a2493857b7d2bc26d5fe30 Mon Sep 17 00:00:00 2001 From: Jack Hooper Date: Wed, 12 Nov 2014 02:04:50 +1100 Subject: Apostrophe fixes as per Python 2 tutorial --- python3.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python3.html.markdown b/python3.html.markdown index e478e57f..0b4feccc 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -7,7 +7,7 @@ contributors: filename: learnpython3.py --- -Python was created by Guido Van Rossum in the early 90's. It is now one of the most popular +Python was created by Guido Van Rossum in the early 90s. It is now one of the most popular languages in existence. I fell in love with Python for its syntactic clarity. It's basically executable pseudocode. @@ -20,7 +20,7 @@ Note: This article applies to Python 3 specifically. Check out the other tutoria # Single line comments start with a number symbol. """ Multiline strings can be written - using three "'s, and are often used + using three "s, and are often used as comments """ @@ -51,7 +51,7 @@ Note: This article applies to Python 3 specifically. Check out the other tutoria # Modulo operation 7 % 3 # => 1 -# Exponentiation (x to the y'th power) +# Exponentiation (x to the yth power) 2**4 # => 16 # Enforce precedence with parentheses -- cgit v1.2.3 From 1c4cbd279e740f4782c62e75d1f4659447dc464a Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Tue, 11 Nov 2014 13:06:57 -0600 Subject: Add colon to introduce the exception handling section --- ruby.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby.html.markdown b/ruby.html.markdown index a1a2c77b..e58c513d 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -272,7 +272,7 @@ else end #=> "OK job" -# exception handling +# exception handling: begin # code here that might raise an exception raise NoMemoryError, 'You ran out of memory.' -- cgit v1.2.3