mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-22 21:52:31 +03:00
Compare commits
6 Commits
8e6a0f974f
...
24d00d55bf
Author | SHA1 | Date | |
---|---|---|---|
|
24d00d55bf | ||
|
a7068ea636 | ||
|
d19c7b0a00 | ||
|
d80cc3caeb | ||
|
2fa3a1126c | ||
|
f6c5e19855 |
@ -90,27 +90,26 @@ addition or not.
|
|||||||
|
|
||||||
## Building the site locally
|
## Building the site locally
|
||||||
|
|
||||||
You can build the site locally to test your changes. Follow the steps below.
|
Install Ruby. On macOS this can be done with [Homebrew](https://brew.sh/).
|
||||||
|
|
||||||
* Install Ruby language runtime and RubyGems. See
|
```sh
|
||||||
[here](https://middlemanapp.com/basics/install/)
|
brew install ruby
|
||||||
for more details.
|
# Install Ruby package manager
|
||||||
* Clone or zip download the
|
gem install bundler
|
||||||
[learnxinyminutes-site](https://github.com/adambard/learnxinyminutes-site)
|
```
|
||||||
repository.
|
|
||||||
* `git clone https://github.com/adambard/learnxinyminutes-site`
|
Then clone two repos, install dependencies and run.
|
||||||
* Install Middleman and other required dependencies using Bundler.
|
|
||||||
* `cd learnxinyminutes-site/`
|
```sh
|
||||||
* `bundle install`
|
# Clone website
|
||||||
* Get the source in place
|
git clone https://github.com/adambard/learnxinyminutes-site
|
||||||
* Copy the contents of your clone of the fork of learnxinyminutes-docs repo
|
# Clone docs (this repo) nested in website
|
||||||
into the `source/docs` folder. There shouldn't be a `learnxinyminutes-docs`
|
git clone https://github.com/<YOUR-USERNAME>/learnxinyminutes-docs ./learnxinyminutes-site/source/docs/
|
||||||
folder inside the `docs` folder, it should just contain all the repo
|
|
||||||
contents.
|
# Install dependencies
|
||||||
* Checkout your fork of the learnxinyminutes-docs repo as `source/docs`.
|
cd learnxinyminutes-site
|
||||||
* `cd source/docs/`
|
bundle install
|
||||||
* `git clone https://github.com/YOUR-USERNAME/learnxinyminutes-docs ./source/docs/`
|
|
||||||
* Build the site or run a development server to test your changes (NOTE: run
|
# Run
|
||||||
these commands at `learnxinyminutes-site/`).
|
bundle exec middleman serve
|
||||||
* Build - `bundle exec middleman build`
|
```
|
||||||
* Dev server - `bundle exec middleman --force-polling --verbose`
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: perl
|
|
||||||
category: language
|
category: language
|
||||||
language: Perl
|
language: Perl
|
||||||
filename: learnperl-bg.pl
|
filename: learnperl-bg.pl
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Go
|
|
||||||
category: language
|
category: language
|
||||||
language: Go
|
language: Go
|
||||||
lang: ca-es
|
lang: ca-es
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Groovy
|
|
||||||
category: language
|
category: language
|
||||||
language: Groovy
|
language: Groovy
|
||||||
lang: ca-es
|
lang: ca-es
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Go
|
|
||||||
category: language
|
category: language
|
||||||
language: Go
|
language: Go
|
||||||
filename: learngo-cs.go
|
filename: learngo-cs.go
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: CUE
|
|
||||||
category: language
|
category: language
|
||||||
language: CUE
|
language: CUE
|
||||||
filename: learncue.cue
|
filename: learncue.cue
|
||||||
|
@ -160,6 +160,8 @@ class Example7Class {
|
|||||||
example7() {
|
example7() {
|
||||||
Example7Class.sayItFromClass();
|
Example7Class.sayItFromClass();
|
||||||
new Example7Class().sayItFromInstance();
|
new Example7Class().sayItFromInstance();
|
||||||
|
//the new keyword is optional, so this is the same
|
||||||
|
Example7Class().sayItFromInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dart supports Generics.
|
/// Dart supports Generics.
|
||||||
@ -175,7 +177,7 @@ example7() {
|
|||||||
/// K,V - Key Value(used for Map)
|
/// K,V - Key Value(used for Map)
|
||||||
class GenericExample<T>{
|
class GenericExample<T>{
|
||||||
void printType(){
|
void printType(){
|
||||||
print("$T")
|
print("$T");
|
||||||
}
|
}
|
||||||
// methods can also have generics
|
// methods can also have generics
|
||||||
genericMethod<M>(){
|
genericMethod<M>(){
|
||||||
@ -200,8 +202,8 @@ class GenericExample<T>{
|
|||||||
const example8List = ["Example8 const array"];
|
const example8List = ["Example8 const array"];
|
||||||
const example8Map = {"someKey": "Example8 const map"};
|
const example8Map = {"someKey": "Example8 const map"};
|
||||||
/// Declare List or Maps as Objects.
|
/// Declare List or Maps as Objects.
|
||||||
List<String> explicitList = new List<String>();
|
List<String> explicitList = <String>[]; //new List<String>() is now
|
||||||
Map<String,dynamic> explicitMaps = new Map<String,dynamic>();
|
Map<String,dynamic> explicitMaps = <String,dynamic>{};
|
||||||
|
|
||||||
explicitList.add("SomeArray");
|
explicitList.add("SomeArray");
|
||||||
example8() {
|
example8() {
|
||||||
@ -214,8 +216,8 @@ example8() {
|
|||||||
/// So when you assign an existing list to a new variable.
|
/// So when you assign an existing list to a new variable.
|
||||||
/// Instead of List, it becomes an Iterable
|
/// Instead of List, it becomes an Iterable
|
||||||
var iterableExplicitList = explicitList;
|
var iterableExplicitList = explicitList;
|
||||||
print(iterableExplicitList) // ("SomeArray"); "[]" becomes "()"
|
print(iterableExplicitList); // ("SomeArray"); "[]" becomes "()"
|
||||||
var newExplicitLists = explicitList.toList() // Converts Iterable<E> to List<E>
|
var newExplicitLists = explicitList.toList(); // Converts Iterable<E> to List<E>
|
||||||
|
|
||||||
/// Loops in Dart take the form of standard for () {} or while () {} loops,
|
/// Loops in Dart take the form of standard for () {} or while () {} loops,
|
||||||
/// slightly more modern for (.. in ..) {}, or functional callbacks with many
|
/// slightly more modern for (.. in ..) {}, or functional callbacks with many
|
||||||
@ -308,13 +310,13 @@ example13() {
|
|||||||
|
|
||||||
/// Boolean expressions support implicit conversions and dynamic type
|
/// Boolean expressions support implicit conversions and dynamic type
|
||||||
example14() {
|
example14() {
|
||||||
var a = true;
|
bool? a = true;
|
||||||
if (a) {
|
if (a) {
|
||||||
print("true, a is $a");
|
print("true, a is $a");
|
||||||
}
|
}
|
||||||
a = false;
|
a = null;
|
||||||
if (a) {
|
if (a ?? false) { //if null count as false
|
||||||
print("true, a is $a");
|
print("true, a is $a");
|
||||||
} else {
|
} else {
|
||||||
print("false, a is $a"); /// runs here
|
print("false, a is $a"); /// runs here
|
||||||
}
|
}
|
||||||
@ -416,39 +418,6 @@ example20() {
|
|||||||
print("Example20 \$ interpolation ${s1} or $s2 works.");
|
print("Example20 \$ interpolation ${s1} or $s2 works.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optional types allow for the annotation of APIs and come to the aid of
|
|
||||||
/// IDEs so the IDEs can better refactor, auto-complete and check for
|
|
||||||
/// errors. So far we haven't declared any types and the programs have
|
|
||||||
/// worked just fine. In fact, types are disregarded during runtime.
|
|
||||||
/// Types can even be wrong and the program will still be given the
|
|
||||||
/// benefit of the doubt and be run as though the types didn't matter.
|
|
||||||
/// There's a runtime parameter that checks for type errors which is
|
|
||||||
/// the checked mode, which is said to be useful during development time,
|
|
||||||
/// but which is also slower because of the extra checking and is thus
|
|
||||||
/// avoided during deployment runtime.
|
|
||||||
class Example21 {
|
|
||||||
List<String> _names;
|
|
||||||
Example21() {
|
|
||||||
_names = ["a", "b"];
|
|
||||||
}
|
|
||||||
List<String> get names => _names;
|
|
||||||
set names(List<String> list) {
|
|
||||||
_names = list;
|
|
||||||
}
|
|
||||||
|
|
||||||
int get length => _names.length;
|
|
||||||
void add(String name) {
|
|
||||||
_names.add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void example21() {
|
|
||||||
Example21 o = new Example21();
|
|
||||||
o.add("c");
|
|
||||||
print("Example21 names '${o.names}' and length '${o.length}'");
|
|
||||||
o.names = ["d", "e"];
|
|
||||||
print("Example21 names '${o.names}' and length '${o.length}'");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Class inheritance takes the form of class name extends AnotherClassName {}.
|
/// Class inheritance takes the form of class name extends AnotherClassName {}.
|
||||||
class Example22A {
|
class Example22A {
|
||||||
@ -470,7 +439,7 @@ example22() {
|
|||||||
/// Mixin is mostly used to share methods with distant classes, so the
|
/// Mixin is mostly used to share methods with distant classes, so the
|
||||||
/// single inheritance doesn't get in the way of reusable code.
|
/// single inheritance doesn't get in the way of reusable code.
|
||||||
/// Mixins follow the "with" statement during the class declaration.
|
/// Mixins follow the "with" statement during the class declaration.
|
||||||
class Example23A {}
|
mixin class Example23A {}
|
||||||
|
|
||||||
class Example23Utils {
|
class Example23Utils {
|
||||||
addTwo(n1, n2) {
|
addTwo(n1, n2) {
|
||||||
@ -496,14 +465,14 @@ example23() {
|
|||||||
/// super-parent's constructor.
|
/// super-parent's constructor.
|
||||||
class Example24A {
|
class Example24A {
|
||||||
var _value;
|
var _value;
|
||||||
Example24A({value: "someValue"}) {
|
Example24A({value = "someValue"}) {
|
||||||
_value = value;
|
_value = value;
|
||||||
}
|
}
|
||||||
get value => _value;
|
get value => _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Example24B extends Example24A {
|
class Example24B extends Example24A {
|
||||||
Example24B({value: "someOtherValue"}) : super(value: value);
|
Example24B({value = "someOtherValue"}) : super(value: value);
|
||||||
}
|
}
|
||||||
|
|
||||||
example24() {
|
example24() {
|
||||||
@ -606,7 +575,7 @@ example29() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rand() {
|
rand() {
|
||||||
v = new DM.Random().nextInt(50);
|
v = new math.Random().nextInt(50);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,7 +600,7 @@ example30() {
|
|||||||
top = int.parse("123") ~/ n2,
|
top = int.parse("123") ~/ n2,
|
||||||
bottom = 0;
|
bottom = 0;
|
||||||
top = top ~/ 6;
|
top = top ~/ 6;
|
||||||
gn = new DM.Random().nextInt(top + 1); /// +1 because nextInt top is exclusive
|
gn = new math.Random().nextInt(top + 1); /// +1 because nextInt top is exclusive
|
||||||
print("Example30 Guess a number between 0 and ${top}");
|
print("Example30 Guess a number between 0 and ${top}");
|
||||||
guessNumber(i) {
|
guessNumber(i) {
|
||||||
if (n == gn) {
|
if (n == gn) {
|
||||||
@ -709,7 +678,7 @@ main() {
|
|||||||
example6, example7, example8, example9, example10,
|
example6, example7, example8, example9, example10,
|
||||||
example11, example12, example13, example14, example15,
|
example11, example12, example13, example14, example15,
|
||||||
example16, example17, example18, example19, example20,
|
example16, example17, example18, example19, example20,
|
||||||
example21, example22, example23, example24, example25,
|
example22, example23, example24, example25,
|
||||||
example26, example27, example28, example29,
|
example26, example27, example28, example29,
|
||||||
example30 // Adding this comment stops the dart formatter from putting all items on a new line
|
example30 // Adding this comment stops the dart formatter from putting all items on a new line
|
||||||
].forEach((ef) => ef());
|
].forEach((ef) => ef());
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Go
|
|
||||||
category: language
|
category: language
|
||||||
language: Go
|
language: Go
|
||||||
lang: es-es
|
lang: es-es
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: perl
|
|
||||||
category: language
|
category: language
|
||||||
language: Perl
|
language: Perl
|
||||||
filename: learnperl-es.pl
|
filename: learnperl-es.pl
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Raku
|
|
||||||
category: language
|
category: language
|
||||||
language: Raku
|
language: Raku
|
||||||
filename: learnraku-es.raku
|
filename: learnraku-es.raku
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Go
|
|
||||||
category: language
|
category: language
|
||||||
language: Go
|
language: Go
|
||||||
filename: learngo-fi.go
|
filename: learngo-fi.go
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Go
|
|
||||||
category: language
|
category: language
|
||||||
language: Go
|
language: Go
|
||||||
lang: fr-fr
|
lang: fr-fr
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: perl
|
|
||||||
category: language
|
category: language
|
||||||
language: Perl
|
language: Perl
|
||||||
filename: learnperl-fr.pl
|
filename: learnperl-fr.pl
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Go
|
|
||||||
category: language
|
category: language
|
||||||
language: Go
|
language: Go
|
||||||
filename: learngo.go
|
filename: learngo.go
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Go
|
|
||||||
language: Go
|
language: Go
|
||||||
filename: learngo-it.go
|
filename: learngo-it.go
|
||||||
contributors:
|
contributors:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Go
|
|
||||||
category: language
|
category: language
|
||||||
language: Go
|
language: Go
|
||||||
filename: learngo-kr.go
|
filename: learngo-kr.go
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: perl
|
|
||||||
category: language
|
category: language
|
||||||
language: Perl
|
language: Perl
|
||||||
filename: learnperl.pl
|
filename: learnperl.pl
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: perl
|
|
||||||
category: language
|
category: language
|
||||||
language: Perl
|
language: Perl
|
||||||
filename: learnperl-pl.pm
|
filename: learnperl-pl.pm
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Go
|
|
||||||
category: language
|
category: language
|
||||||
language: Go
|
language: Go
|
||||||
filename: learngo-pt.go
|
filename: learngo-pt.go
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: perl
|
|
||||||
category: language
|
category: language
|
||||||
language: Perl
|
language: Perl
|
||||||
filename: learnperl-pt.pl
|
filename: learnperl-pt.pl
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Red
|
|
||||||
category: language
|
category: language
|
||||||
language: Red
|
language: Red
|
||||||
filename: learnred.red
|
filename: learnred.red
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Sing
|
|
||||||
category: language
|
category: language
|
||||||
language: Sing
|
language: Sing
|
||||||
filename: learnsing.sing
|
filename: learnsing.sing
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: C
|
|
||||||
category: language
|
category: language
|
||||||
language: C
|
language: C
|
||||||
filename: learnc-tr.c
|
filename: learnc-tr.c
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: ruby
|
|
||||||
language: Ruby
|
language: Ruby
|
||||||
filename: learnruby-tr.rb
|
filename: learnruby-tr.rb
|
||||||
contributors:
|
contributors:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Go
|
|
||||||
category: language
|
category: language
|
||||||
language: Go
|
language: Go
|
||||||
filename: learngo-ua.go
|
filename: learngo-ua.go
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: java
|
|
||||||
category: language
|
category: language
|
||||||
language: Java
|
language: Java
|
||||||
lang: zh-cn
|
lang: zh-cn
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
language: JavaScript
|
language: JavaScript
|
||||||
category: language
|
category: language
|
||||||
name: javascript
|
|
||||||
filename: javascript-zh.js
|
filename: javascript-zh.js
|
||||||
contributors:
|
contributors:
|
||||||
- ["Leigh Brenecki", "https://leigh.net.au"]
|
- ["Leigh Brenecki", "https://leigh.net.au"]
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: perl
|
|
||||||
category: language
|
category: language
|
||||||
language: Perl
|
language: Perl
|
||||||
filename: learnperl-cn.pl
|
filename: learnperl-cn.pl
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: Red
|
|
||||||
category: language
|
category: language
|
||||||
language: Red
|
language: Red
|
||||||
filename: LearnRed-zh.red
|
filename: LearnRed-zh.red
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
language: javascript
|
language: JavaScript
|
||||||
category: language
|
category: language
|
||||||
name: javascript
|
|
||||||
filename: javascript-zh-tw.js
|
filename: javascript-zh-tw.js
|
||||||
contributors:
|
contributors:
|
||||||
- ["Leigh Brenecki", "https://leigh.net.au"]
|
- ["Leigh Brenecki", "https://leigh.net.au"]
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
name: perl
|
|
||||||
category: language
|
category: language
|
||||||
language: Perl
|
language: Perl
|
||||||
filename: learnperl-tw.pl
|
filename: learnperl-tw.pl
|
||||||
|
Loading…
Reference in New Issue
Block a user