1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-12 17:54:26 +02:00

Merge pull request #748 from levibostian/clean-up-issues

Clean up issues
This commit is contained in:
Nami-Doc
2014-09-08 21:53:11 +02:00
4 changed files with 18 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ contributors:
- ["Denis Arh", "https://github.com/darh"] - ["Denis Arh", "https://github.com/darh"]
- ["akirahirose", "https://twitter.com/akirahirose"] - ["akirahirose", "https://twitter.com/akirahirose"]
- ["Anton Strömkvist", "http://lutic.org/"] - ["Anton Strömkvist", "http://lutic.org/"]
- ["Rahil Momin", "https://github.com/iamrahil"]
filename: LearnBash.sh filename: LearnBash.sh
--- ---
@@ -140,6 +141,12 @@ do
echo "$VARIABLE" echo "$VARIABLE"
done done
# Or write it the "traditional for loop" way:
for ((a=1; a <= 3; a++))
do
echo $a
done
# They can also be used to act on files.. # They can also be used to act on files..
# This will run the command 'cat' on file1 and file2 # This will run the command 'cat' on file1 and file2
for VARIABLE in file1 file2 for VARIABLE in file1 file2

View File

@@ -4,6 +4,7 @@ filename: learnc.c
contributors: contributors:
- ["Adam Bard", "http://adambard.com/"] - ["Adam Bard", "http://adambard.com/"]
- ["Árpád Goretity", "http://twitter.com/H2CO3_iOS"] - ["Árpád Goretity", "http://twitter.com/H2CO3_iOS"]
- ["Jakub Trzebiatowski", "http://cbs.stgn.pl"]
--- ---
@@ -175,6 +176,9 @@ int main() {
i2 * i1; // => 2 i2 * i1; // => 2
i1 / i2; // => 0 (0.5, but truncated towards 0) i1 / i2; // => 0 (0.5, but truncated towards 0)
// You need to cast at least one integer to float to get a floating-point result
(float)i1 / i2 // => 0.5f
i1 / (double)i2 // => 0.5 // Same with double
f1 / f2; // => 0.5, plus or minus epsilon f1 / f2; // => 0.5, plus or minus epsilon
// Floating-point numbers and calculations are not exact // Floating-point numbers and calculations are not exact
@@ -194,9 +198,11 @@ int main() {
2 >= 2; // => 1 2 >= 2; // => 1
// C is not Python - comparisons don't chain. // C is not Python - comparisons don't chain.
// WRONG: // Warning: The line below will compile, but it means `(0 < a) < 2`.
//int between_0_and_2 = 0 < a < 2; // This expression is always true, because (0 < a) could be either 1 or 0.
// Correct: // In this case it's 1, because (0 < 1).
int between_0_and_2 = 0 < a < 2;
// Instead use:
int between_0_and_2 = 0 < a && a < 2; int between_0_and_2 = 0 < a && a < 2;
// Logic works on ints // Logic works on ints

View File

@@ -9,6 +9,7 @@ contributors:
- ["Amr Tamimi", "https://amrtamimi.com"] - ["Amr Tamimi", "https://amrtamimi.com"]
translators: translators:
- ["Jakukyo Friel", "http://weakish.github.io"] - ["Jakukyo Friel", "http://weakish.github.io"]
filename: lua-cn.lua
--- ---
```lua ```lua

View File

@@ -3,7 +3,7 @@ language: Markdown
contributors: contributors:
- ["Dan Turkel", "http://danturkel.com/"] - ["Dan Turkel", "http://danturkel.com/"]
translators: translators:
- ["Fangzhou Chen"] - ["Fangzhou Chen","https://github.com/FZSS"]
filename: learnmarkdown-cn.md filename: learnmarkdown-cn.md
lang: zh-cn lang: zh-cn
--- ---