Compare commits

...

6 Commits

Author SHA1 Message Date
Nayden Gochev
24d00d55bf
Merge 2fa3a1126c into a7068ea636 2024-11-06 10:22:57 +05:30
Maciej Kasprzyk
a7068ea636
docs: edit contributing, how to build (#5163) 2024-10-30 14:47:12 -06:00
Boris Verkhovskiy
d19c7b0a00 Make instructions faster to copy/paste 2024-10-29 23:29:13 -06:00
Boris Verkhovskiy
d80cc3caeb
Remove "name:" (#5161) 2024-10-29 21:13:04 -06:00
Boris Verkhovskiy
2fa3a1126c
Merge branch 'master' into master 2024-05-15 21:26:58 -06:00
gochev
f6c5e19855 updating the dart examples to work against dart 3.0 2023-05-24 11:49:40 +03:00
31 changed files with 40 additions and 101 deletions

View File

@ -90,27 +90,26 @@ addition or not.
## 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
[here](https://middlemanapp.com/basics/install/)
for more details.
* Clone or zip download the
[learnxinyminutes-site](https://github.com/adambard/learnxinyminutes-site)
repository.
* `git clone https://github.com/adambard/learnxinyminutes-site`
* Install Middleman and other required dependencies using Bundler.
* `cd learnxinyminutes-site/`
* `bundle install`
* Get the source in place
* Copy the contents of your clone of the fork of learnxinyminutes-docs repo
into the `source/docs` folder. There shouldn't be a `learnxinyminutes-docs`
folder inside the `docs` folder, it should just contain all the repo
contents.
* Checkout your fork of the learnxinyminutes-docs repo as `source/docs`.
* `cd source/docs/`
* `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
these commands at `learnxinyminutes-site/`).
* Build - `bundle exec middleman build`
* Dev server - `bundle exec middleman --force-polling --verbose`
```sh
brew install ruby
# Install Ruby package manager
gem install bundler
```
Then clone two repos, install dependencies and run.
```sh
# Clone website
git clone https://github.com/adambard/learnxinyminutes-site
# Clone docs (this repo) nested in website
git clone https://github.com/<YOUR-USERNAME>/learnxinyminutes-docs ./learnxinyminutes-site/source/docs/
# Install dependencies
cd learnxinyminutes-site
bundle install
# Run
bundle exec middleman serve
```

View File

@ -1,5 +1,4 @@
---
name: perl
category: language
language: Perl
filename: learnperl-bg.pl

View File

@ -1,5 +1,4 @@
---
name: Go
category: language
language: Go
lang: ca-es

View File

@ -1,5 +1,4 @@
---
name: Groovy
category: language
language: Groovy
lang: ca-es

View File

@ -1,5 +1,4 @@
---
name: Go
category: language
language: Go
filename: learngo-cs.go

View File

@ -1,5 +1,4 @@
---
name: CUE
category: language
language: CUE
filename: learncue.cue

View File

@ -160,6 +160,8 @@ class Example7Class {
example7() {
Example7Class.sayItFromClass();
new Example7Class().sayItFromInstance();
//the new keyword is optional, so this is the same
Example7Class().sayItFromInstance();
}
/// Dart supports Generics.
@ -175,7 +177,7 @@ example7() {
/// K,V - Key Value(used for Map)
class GenericExample<T>{
void printType(){
print("$T")
print("$T");
}
// methods can also have generics
genericMethod<M>(){
@ -200,8 +202,8 @@ class GenericExample<T>{
const example8List = ["Example8 const array"];
const example8Map = {"someKey": "Example8 const map"};
/// Declare List or Maps as Objects.
List<String> explicitList = new List<String>();
Map<String,dynamic> explicitMaps = new Map<String,dynamic>();
List<String> explicitList = <String>[]; //new List<String>() is now
Map<String,dynamic> explicitMaps = <String,dynamic>{};
explicitList.add("SomeArray");
example8() {
@ -214,8 +216,8 @@ example8() {
/// So when you assign an existing list to a new variable.
/// Instead of List, it becomes an Iterable
var iterableExplicitList = explicitList;
print(iterableExplicitList) // ("SomeArray"); "[]" becomes "()"
var newExplicitLists = explicitList.toList() // Converts Iterable<E> to List<E>
print(iterableExplicitList); // ("SomeArray"); "[]" becomes "()"
var newExplicitLists = explicitList.toList(); // Converts Iterable<E> to List<E>
/// Loops in Dart take the form of standard for () {} or while () {} loops,
/// slightly more modern for (.. in ..) {}, or functional callbacks with many
@ -308,13 +310,13 @@ example13() {
/// Boolean expressions support implicit conversions and dynamic type
example14() {
var a = true;
bool? a = true;
if (a) {
print("true, a is $a");
}
a = false;
if (a) {
print("true, a is $a");
a = null;
if (a ?? false) { //if null count as false
print("true, a is $a");
} else {
print("false, a is $a"); /// runs here
}
@ -416,39 +418,6 @@ example20() {
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 Example22A {
@ -470,7 +439,7 @@ example22() {
/// Mixin is mostly used to share methods with distant classes, so the
/// single inheritance doesn't get in the way of reusable code.
/// Mixins follow the "with" statement during the class declaration.
class Example23A {}
mixin class Example23A {}
class Example23Utils {
addTwo(n1, n2) {
@ -496,14 +465,14 @@ example23() {
/// super-parent's constructor.
class Example24A {
var _value;
Example24A({value: "someValue"}) {
Example24A({value = "someValue"}) {
_value = value;
}
get value => _value;
}
class Example24B extends Example24A {
Example24B({value: "someOtherValue"}) : super(value: value);
Example24B({value = "someOtherValue"}) : super(value: value);
}
example24() {
@ -606,7 +575,7 @@ example29() {
}
rand() {
v = new DM.Random().nextInt(50);
v = new math.Random().nextInt(50);
return v;
}
@ -631,7 +600,7 @@ example30() {
top = int.parse("123") ~/ n2,
bottom = 0;
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}");
guessNumber(i) {
if (n == gn) {
@ -709,7 +678,7 @@ main() {
example6, example7, example8, example9, example10,
example11, example12, example13, example14, example15,
example16, example17, example18, example19, example20,
example21, example22, example23, example24, example25,
example22, example23, example24, example25,
example26, example27, example28, example29,
example30 // Adding this comment stops the dart formatter from putting all items on a new line
].forEach((ef) => ef());

View File

@ -1,5 +1,4 @@
---
name: Go
category: language
language: Go
lang: es-es

View File

@ -1,5 +1,4 @@
---
name: perl
category: language
language: Perl
filename: learnperl-es.pl

View File

@ -1,5 +1,4 @@
---
name: Raku
category: language
language: Raku
filename: learnraku-es.raku

View File

@ -1,5 +1,4 @@
---
name: Go
category: language
language: Go
filename: learngo-fi.go

View File

@ -1,5 +1,4 @@
---
name: Go
category: language
language: Go
lang: fr-fr

View File

@ -1,5 +1,4 @@
---
name: perl
category: language
language: Perl
filename: learnperl-fr.pl

View File

@ -1,5 +1,4 @@
---
name: Go
category: language
language: Go
filename: learngo.go

View File

@ -1,5 +1,4 @@
---
name: Go
language: Go
filename: learngo-it.go
contributors:

View File

@ -1,5 +1,4 @@
---
name: Go
category: language
language: Go
filename: learngo-kr.go

View File

@ -1,5 +1,4 @@
---
name: perl
category: language
language: Perl
filename: learnperl.pl

View File

@ -1,5 +1,4 @@
---
name: perl
category: language
language: Perl
filename: learnperl-pl.pm

View File

@ -1,5 +1,4 @@
---
name: Go
category: language
language: Go
filename: learngo-pt.go

View File

@ -1,5 +1,4 @@
---
name: perl
category: language
language: Perl
filename: learnperl-pt.pl

View File

@ -1,5 +1,4 @@
---
name: Red
category: language
language: Red
filename: learnred.red

View File

@ -1,5 +1,4 @@
---
name: Sing
category: language
language: Sing
filename: learnsing.sing

View File

@ -1,5 +1,4 @@
---
name: C
category: language
language: C
filename: learnc-tr.c

View File

@ -1,5 +1,4 @@
---
name: ruby
language: Ruby
filename: learnruby-tr.rb
contributors:

View File

@ -1,5 +1,4 @@
---
name: Go
category: language
language: Go
filename: learngo-ua.go

View File

@ -1,5 +1,4 @@
---
name: java
category: language
language: Java
lang: zh-cn

View File

@ -1,7 +1,6 @@
---
language: JavaScript
category: language
name: javascript
filename: javascript-zh.js
contributors:
- ["Leigh Brenecki", "https://leigh.net.au"]

View File

@ -1,5 +1,4 @@
---
name: perl
category: language
language: Perl
filename: learnperl-cn.pl

View File

@ -1,5 +1,4 @@
---
name: Red
category: language
language: Red
filename: LearnRed-zh.red

View File

@ -1,7 +1,6 @@
---
language: javascript
language: JavaScript
category: language
name: javascript
filename: javascript-zh-tw.js
contributors:
- ["Leigh Brenecki", "https://leigh.net.au"]

View File

@ -1,5 +1,4 @@
---
name: perl
category: language
language: Perl
filename: learnperl-tw.pl