Skip to content

WIP: merging look and feel of scala-lang with doc site #806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 125 commits into from
Aug 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
ac49a07
Update JSON, add redirect-from
travissarles May 5, 2017
cc88ed1
Guides to replace overviews landing
travissarles May 5, 2017
814e2a6
Updated description
travissarles May 5, 2017
d39f6cd
Ignore ruby version
travissarles May 8, 2017
d4b0479
updated json
travissarles May 26, 2017
4085615
jekyll-redirect-from
travissarles May 26, 2017
83cf79b
bumped scala version
travissarles May 26, 2017
531539d
Added redirect-from gem
travissarles May 26, 2017
6a03b97
New headers
travissarles May 26, 2017
970b29d
replaced layouts
travissarles May 26, 2017
ad2c2b0
new index page
travissarles May 26, 2017
6a62ca9
removed spanish overviews.index.md
travissarles May 26, 2017
2940964
replaced old resources
travissarles May 27, 2017
78c6e15
new images
travissarles May 27, 2017
3c3ab87
Getting started and docs landing pages
travissarles May 27, 2017
fb6231a
replaced tutorial layout
travissarles May 27, 2017
b442c58
changed overview layout
travissarles May 27, 2017
996b384
replaced sip layout with ipnm
travissarles May 27, 2017
07ea3b2
replaced guides-index layout
travissarles May 27, 2017
b7dfd58
fixed ipnm-landing typo
travissarles May 27, 2017
967d959
deleted partest guide
travissarles May 27, 2017
ed801fd
style index page
travissarles May 29, 2017
6caabcf
Fixed basics layout
travissarles May 29, 2017
d658a28
Merge branch 'copychanges'
travissarles May 29, 2017
8cf20c5
replaced redirected layout
travissarles May 29, 2017
0a0a8db
Updated layout
travissarles May 29, 2017
2eb980d
redirect tutorials index page to tour of scala
travissarles May 29, 2017
46552d1
Unused search page
travissarles May 29, 2017
94f2190
Fixed glossary
travissarles May 29, 2017
5999a0f
changed CNAME for running on github
travissarles May 29, 2017
2a68518
Fixed padding
travissarles May 29, 2017
aa4245c
Merge branch 'copychanges'
travissarles May 29, 2017
6cbc067
changed back CNAME
travissarles May 29, 2017
62a95a7
Updated links to glossary/cheatsheet
travissarles May 30, 2017
9f64f88
Updated layout for thanks
travissarles May 30, 2017
e9678b0
Updated contribute layout
travissarles May 30, 2017
1112f5d
fixed cheatsheet layout
travissarles May 30, 2017
ee0f6c5
fixed glossary layout
travissarles May 30, 2017
bc77126
fixed contributing header
travissarles May 30, 2017
9aff2f7
Merge branch 'copychanges'
travissarles May 30, 2017
8b1d76c
books collection
travissarles May 31, 2017
e604768
fixed formatting
travissarles May 31, 2017
ae23929
fixed urls
travissarles May 31, 2017
cd2d0b1
changed tour layout
travissarles May 31, 2017
18116b7
Merge branch 'copychanges'
travissarles May 31, 2017
de6ed33
Chagned tour layout
travissarles Jun 1, 2017
a98a8ec
Tour layout helpers
travissarles Jun 1, 2017
7edc511
Language bar fixed
travissarles Jun 1, 2017
ac489e8
Delete migrating from 2.7
travissarles Jun 3, 2017
8ae0c34
Language bar in contents bar
travissarles Jun 3, 2017
1627215
Merge branch 'copychanges'
travissarles Jun 3, 2017
31fdce9
Merge remote-tracking branch 'upstream/master' into testmerge
travissarles Jun 22, 2017
3bf9124
fixed merge conflicts
travissarles Jun 22, 2017
689cfed
Merge branch 'master' of https://github.com/travissarles/scala.github…
heathermiller Jul 14, 2017
7213a12
Replacing css with sass
heathermiller Jul 14, 2017
7b3da30
Add responsive nav bar custom for doc site
heathermiller Jul 19, 2017
3937ef2
Merge branch 'master' into travissarles-master
heathermiller Jul 19, 2017
4a9e1bc
Oh my god how did tabs sneak into my commit!? Ew!
heathermiller Jul 19, 2017
b738eae
Merge branch 'travissarles-master' of github.com:scala/scala.github.c…
heathermiller Jul 19, 2017
1cbb5c0
Books page added
heathermiller Jul 19, 2017
6a17804
Fixes to Book page add
heathermiller Jul 19, 2017
51e23c3
New overviews landing page
heathermiller Jul 21, 2017
0e336c2
More work on the overview index page
heathermiller Jul 22, 2017
3d5de87
Merge branch 'master' into travissarles-master
heathermiller Jul 22, 2017
66422f2
Overview index page finished
heathermiller Jul 24, 2017
04a52b7
Merge branch 'travissarles-master' of github.com:scala/scala.github.c…
heathermiller Jul 24, 2017
1febc3f
Fix conflicts
heathermiller Jul 24, 2017
4064365
WIP on multi-page TOCs
heathermiller Jul 25, 2017
ad80b62
More WIP on TOCs
heathermiller Jul 25, 2017
44840f5
Overviews almost overhauled
heathermiller Jul 26, 2017
ffef427
Translation toggle now works
heathermiller Jul 26, 2017
207980e
Some Japanese and Chinese translations
heathermiller Jul 26, 2017
0a78fc3
More overview translations ready
heathermiller Jul 26, 2017
7267efb
Working on single-page translation documentation
heathermiller Jul 26, 2017
4737955
Rest of the single-page overview translations
heathermiller Jul 26, 2017
370d0ad
Rest of the single page overviews (pt 2)
heathermiller Jul 26, 2017
cfe9168
Scala tour formatting, language switch, and es & ba translations
heathermiller Jul 27, 2017
1bb099f
Straggler (ba translation)
heathermiller Jul 27, 2017
e5b6a7d
Rest of translations for Scala Tour
heathermiller Jul 27, 2017
714a36d
Merge branch 'master' into travissarles-master
heathermiller Jul 27, 2017
1412f25
Organizing tutorials/FAQs
heathermiller Jul 27, 2017
98d24ae
Keep tut AND syntax highlighting both w/ Jekyll plugin
heathermiller Jul 27, 2017
1ec1fc8
Sidebar bugfix and work on tutorials
heathermiller Jul 27, 2017
eb36bec
Cleaning up dependencies
heathermiller Jul 27, 2017
00d73a5
Scala for Java programmers tutorials, good to go
heathermiller Jul 27, 2017
4c49b4a
Updating drone image (syncing Ruby versions with production server)
heathermiller Jul 27, 2017
d7447d5
Glossary finished
heathermiller Jul 27, 2017
eb5eb7e
WIP documentation index page
heathermiller Jul 27, 2017
b2603c4
Drone updates
heathermiller Jul 27, 2017
79b0036
More messing with drone
heathermiller Jul 27, 2017
a03e0a6
More drone BS. This is the last effing time. Gah.
heathermiller Jul 27, 2017
384e6b9
!!!!!
heathermiller Jul 27, 2017
f8c2786
Get rid of cruft
heathermiller Jul 27, 2017
2ae27bf
Cheatsheet styling
heathermiller Jul 27, 2017
297b658
Cheatsheets finished
heathermiller Jul 27, 2017
ce17c3b
Style tweaks to index page of style guide
heathermiller Jul 29, 2017
b683b98
Replacing accidentally deleted overview index
heathermiller Jul 29, 2017
be7fe8e
Fix up the card design on the overview index page
heathermiller Jul 29, 2017
9472c35
Reworked getting started index
heathermiller Jul 29, 2017
7589f4d
Wording tweaks to getting started index
heathermiller Jul 30, 2017
4a220b0
Improvements to the getting started guide (IntelliJ part)
heathermiller Jul 30, 2017
55b001b
Improvements to the getting started guide (sbt part)
heathermiller Jul 30, 2017
3413d2e
Adding list of all API docs
heathermiller Jul 30, 2017
020b1eb
Work on SIP landing page
heathermiller Jul 30, 2017
8b4fefc
WIP SIP section
heathermiller Jul 30, 2017
90c18f7
More work on SIP section
heathermiller Jul 30, 2017
81701c0
More SIP section progress
heathermiller Jul 30, 2017
e2383ed
More SIP progress
heathermiller Jul 30, 2017
a978887
WIP SIPs: shuffling files around
heathermiller Jul 30, 2017
d2fa8c9
More progress on SIPs
heathermiller Jul 30, 2017
5eb130e
Work on SIP list
heathermiller Jul 30, 2017
56a0a59
SIP tweaks
heathermiller Jul 30, 2017
7665171
Sidebar for SIP index pages
heathermiller Jul 31, 2017
ed73f4e
SIPs site getting close...
heathermiller Jul 31, 2017
11e336a
SIP site finished, I think
heathermiller Jul 31, 2017
565703c
SIP minutes list: most recent meetings first
heathermiller Jul 31, 2017
c79b609
Footer added + 1 SIP straggler
heathermiller Jul 31, 2017
df9348d
Adding quasiquotes guide, styling experimental labels
heathermiller Jul 31, 2017
75334ca
Tutorials index page
heathermiller Jul 31, 2017
6fd77f0
Index page, done, I think.
heathermiller Jul 31, 2017
7f94f71
Learning resources page
heathermiller Jul 31, 2017
74374e9
Clean ups
heathermiller Jul 31, 2017
863161d
More tidying
heathermiller Jul 31, 2017
623fd8b
Image path tweaks
heathermiller Jul 31, 2017
fb0793e
Removing tutorial index page, as per @tpolecat's advice
heathermiller Jul 31, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 2 additions & 5 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
pipeline:
build:
image: scalaplatform/jdk8-ruby2-coursier:0.1
image: scalacenter/scala-rvm-jvm-coursier:2.0
pull: true
commands:
- bundle install
- ./scripts/run-tut.sh
- rm -r tut-tmp
- bundle exec jekyll build
- ./scripts/ci.sh
2 changes: 1 addition & 1 deletion .drone.yml.sig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgYnVpbGQ6CiAgICBpbWFnZTogc2NhbGFwbGF0Zm9ybS9qZGs4LXJ1YnkyLWNvdXJzaWVyOjAuMQogICAgcHVsbDogdHJ1ZQogICAgY29tbWFuZHM6CiAgICAgIC0gYnVuZGxlIGluc3RhbGwKICAgICAgLSAuL3NjcmlwdHMvcnVuLXR1dC5zaAogICAgICAtIHJtIC1yIHR1dC10bXAKICAgICAgLSBidW5kbGUgZXhlYyBqZWt5bGwgYnVpbGQK.uCV-tIDp9xbL2u2y27B9id6SL89dBfiiiTvVXYxHAbw
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgYnVpbGQ6CiAgICBpbWFnZTogamRrLXJ2bS1jb3Vyc2llcjpsYXRlc3QKICAgIHB1bGw6IHRydWUKICAgIGNvbW1hbmRzOgogICAgICAtIHNvdXJjZSB-Ly5wcm9maWxlCiAgICAgIC0gYnVuZGxlIGluc3RhbGwKICAgICAgLSAuL3NjcmlwdHMvcnVuLXR1dC5zaAogICAgICAtIHJtIC1yIHR1dC10bXAKICAgICAgLSBidW5kbGUgZXhlYyBqZWt5bGwgYnVpbGQK.7Rp37FEwRqAo85EdFYZh1PoyU8mxpFdEnpchWaQkHCc
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_site
.ruby-version
.DS_Store
.project
.settings
Expand All @@ -8,3 +9,4 @@ vendor/bundle
.idea/
/coursier
/tut-tmp/
.sass-cache/
11 changes: 10 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
source 'https://rubygems.org'
gem 'github-pages', group: :jekyll_plugins
gem 'jekyll-redirect-from'

# group :jekyll_plugins do
# gem 'hawkins'
# end

# ^ Useful for live reloading the site in your
# browser during development. To use, uncomment
# and do:
# bundle exec jekyll liveserve --incremental
168 changes: 9 additions & 159 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,173 +1,34 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.8)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
colorator (1.1.0)
ethon (0.10.1)
ffi (>= 1.3.0)
execjs (2.7.0)
faraday (0.12.1)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
forwardable-extended (2.6.0)
gemoji (3.0.0)
github-pages (143)
activesupport (= 4.2.8)
github-pages-health-check (= 1.3.4)
jekyll (= 3.4.5)
jekyll-avatar (= 0.4.2)
jekyll-coffeescript (= 1.0.1)
jekyll-default-layout (= 0.1.4)
jekyll-feed (= 0.9.2)
jekyll-gist (= 1.4.0)
jekyll-github-metadata (= 2.4.0)
jekyll-mentions (= 1.2.0)
jekyll-optional-front-matter (= 0.1.2)
jekyll-paginate (= 1.1.0)
jekyll-readme-index (= 0.1.0)
jekyll-redirect-from (= 0.12.1)
jekyll-relative-links (= 0.4.1)
jekyll-sass-converter (= 1.5.0)
jekyll-seo-tag (= 2.2.3)
jekyll-sitemap (= 1.0.0)
jekyll-swiss (= 0.4.0)
jekyll-theme-architect (= 0.0.4)
jekyll-theme-cayman (= 0.0.4)
jekyll-theme-dinky (= 0.0.4)
jekyll-theme-hacker (= 0.0.4)
jekyll-theme-leap-day (= 0.0.4)
jekyll-theme-merlot (= 0.0.4)
jekyll-theme-midnight (= 0.0.4)
jekyll-theme-minimal (= 0.0.4)
jekyll-theme-modernist (= 0.0.4)
jekyll-theme-primer (= 0.3.0)
jekyll-theme-slate (= 0.0.4)
jekyll-theme-tactile (= 0.0.4)
jekyll-theme-time-machine (= 0.0.4)
jekyll-titles-from-headings (= 0.2.0)
jemoji (= 0.8.0)
kramdown (= 1.13.2)
liquid (= 3.0.6)
listen (= 3.0.6)
mercenary (~> 0.3)
minima (= 2.1.1)
rouge (= 1.11.1)
terminal-table (~> 1.4)
github-pages-health-check (1.3.4)
addressable (~> 2.3)
net-dns (~> 0.8)
octokit (~> 4.0)
public_suffix (~> 2.0)
typhoeus (~> 0.7)
html-pipeline (2.6.0)
activesupport (>= 2)
nokogiri (>= 1.4)
i18n (0.8.6)
jekyll (3.4.5)
jekyll (3.5.1)
addressable (~> 2.4)
colorator (~> 1.0)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 1.1)
kramdown (~> 1.3)
liquid (~> 3.0)
liquid (~> 4.0)
mercenary (~> 0.3.3)
pathutil (~> 0.9)
rouge (~> 1.7)
safe_yaml (~> 1.0)
jekyll-avatar (0.4.2)
jekyll (~> 3.0)
jekyll-coffeescript (1.0.1)
coffee-script (~> 2.2)
jekyll-default-layout (0.1.4)
jekyll (~> 3.0)
jekyll-feed (0.9.2)
jekyll (~> 3.3)
jekyll-gist (1.4.0)
octokit (~> 4.2)
jekyll-github-metadata (2.4.0)
jekyll (~> 3.1)
octokit (~> 4.0, != 4.4.0)
jekyll-mentions (1.2.0)
activesupport (~> 4.0)
html-pipeline (~> 2.3)
jekyll (~> 3.0)
jekyll-optional-front-matter (0.1.2)
jekyll (~> 3.0)
jekyll-paginate (1.1.0)
jekyll-readme-index (0.1.0)
jekyll (~> 3.0)
jekyll-redirect-from (0.12.1)
jekyll (~> 3.3)
jekyll-relative-links (0.4.1)
jekyll (~> 3.3)
jekyll-sass-converter (1.5.0)
sass (~> 3.4)
jekyll-seo-tag (2.2.3)
jekyll (~> 3.3)
jekyll-sitemap (1.0.0)
jekyll (~> 3.3)
jekyll-swiss (0.4.0)
jekyll-theme-architect (0.0.4)
jekyll (~> 3.3)
jekyll-theme-cayman (0.0.4)
jekyll (~> 3.3)
jekyll-theme-dinky (0.0.4)
jekyll (~> 3.3)
jekyll-theme-hacker (0.0.4)
jekyll (~> 3.3)
jekyll-theme-leap-day (0.0.4)
jekyll (~> 3.3)
jekyll-theme-merlot (0.0.4)
jekyll (~> 3.3)
jekyll-theme-midnight (0.0.4)
jekyll (~> 3.3)
jekyll-theme-minimal (0.0.4)
jekyll (~> 3.3)
jekyll-theme-modernist (0.0.4)
jekyll (~> 3.3)
jekyll-theme-primer (0.3.0)
jekyll (~> 3.3)
jekyll-theme-slate (0.0.4)
jekyll (~> 3.3)
jekyll-theme-tactile (0.0.4)
jekyll (~> 3.3)
jekyll-theme-time-machine (0.0.4)
jekyll (~> 3.3)
jekyll-titles-from-headings (0.2.0)
jekyll (~> 3.3)
jekyll-watch (1.5.0)
listen (~> 3.0, < 3.1)
jemoji (0.8.0)
activesupport (~> 4.0)
gemoji (~> 3.0)
html-pipeline (~> 2.2)
jekyll (>= 3.0)
kramdown (1.13.2)
liquid (3.0.6)
listen (3.0.6)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9.7)
kramdown (1.14.0)
liquid (4.0.0)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
mercenary (0.3.6)
mini_portile2 (2.1.0)
minima (2.1.1)
jekyll (~> 3.3)
minitest (5.10.2)
multipart-post (2.0.0)
net-dns (0.8.0)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
octokit (4.7.0)
sawyer (~> 0.8.0, >= 0.5.3)
pathutil (0.14.0)
forwardable-extended (~> 2.6)
public_suffix (2.0.5)
Expand All @@ -181,23 +42,12 @@ GEM
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thread_safe (0.3.6)
typhoeus (0.8.0)
ethon (>= 0.8.0)
tzinfo (1.2.3)
thread_safe (~> 0.1)
unicode-display_width (1.3.0)

PLATFORMS
ruby

DEPENDENCIES
github-pages
jekyll-redirect-from

BUNDLED WITH
1.15.1
1.15.3
88 changes: 88 additions & 0 deletions _ba/cheatsheets/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
layout: cheatsheet
title: Scalacheat

partof: cheatsheet

by: Brendan O'Connor
about: Zahvaljujući <a href="http://brenocon.com/">Brendan O'Connor</a>u ovaj cheatsheet teži da bude kratki pregled sintakse Scale. Licenca pripada Brendan O'Connor-u, pod CC-BY-SA 3.0 licencom.

language: ba
---

###### Doprinio {{ page.by }}
{{ page.about }}

| <span id="variables" class="h2">varijable</span> | |
| `var x = 5` | varijabla. |
| <span class="label success">Dobro</span> `val x = 5`<br> <span class="label important">Loše</span> `x=6` | konstanta. |
| `var x: Double = 5` | eksplicitni tip. |
| <span id="functions" class="h2">funkcije</span> | |
| <span class="label success">Dobro</span> `def f(x: Int) = { x*x }`<br> <span class="label important">Loše</span> `def f(x: Int) { x*x }` | definicija funkcije. <br> skrivena greška: bez `=` ovo je procedura koja vraća `Unit`; uzrokuje zabunu. |
| <span class="label success">Dobro</span> `def f(x: Any) = println(x)`<br> <span class="label important">Loše</span> `def f(x) = println(x)` | definicija funkcije. <br> sintaksna greška: potrebni su tipovi za svaki argument. |
| `type R = Double` | pseudonim za tip. |
| `def f(x: R)` ili<br> `def f(x: => R)` | poziv-po-vrijednosti. <br> poziv-po-imenu (lijeni parameteri). |
| `(x:R) => x*x` | anonimna funkcija. |
| `(1 to 5).map(_*2)` ili<br> `(1 to 5).reduceLeft( _+_ )` | anonimna funkcija: donja crta odgovara argumentu po poziciji. |
| `(1 to 5).map( x => x*x )` | anonimna funkcija: da bi koristili argument više od jednom, morate mu dati ime. |
| <span class="label success">Dobro</span> `(1 to 5).map(2*)`<br> <span class="label important">Loše</span> `(1 to 5).map(*2)` | anonimna funkcija: vezana infiksna metoda. Koristite `2*_` zbog jasnoće. |
| `(1 to 5).map { x => val y=x*2; println(y); y }` | anonimna funkcija: blokovski stil vraća vrijednost zadnjeg izraza. |
| `(1 to 5) filter {_%2 == 0} map {_*2}` | anonimne funkcije: pipeline stil (može i sa oblim zagradama). |
| `def compose(g:R=>R, h:R=>R) = (x:R) => g(h(x))` <br> `val f = compose({_*2}, {_-1})` | anonimne funkcije: da bi proslijedili više blokova, potrebne su dodatne zagrade. |
| `val zscore = (mean:R, sd:R) => (x:R) => (x-mean)/sd` | curry-jevanje, očita sintaksa. |
| `def zscore(mean:R, sd:R) = (x:R) => (x-mean)/sd` | curry-jevanje, očita sintaksa. |
| `def zscore(mean:R, sd:R)(x:R) = (x-mean)/sd` | curry-jevanje, sintaksni šećer (kratica). Ali onda: |
| `val normer = zscore(7, 0.4) _` | je potrebna prateća donja crta za parcijalnu primjenu, samo kod šećer (skraćene) verzije. |
| `def mapmake[T](g:T=>T)(seq: List[T]) = seq.map(g)` | generički tip. |
| `5.+(3); 5 + 3` <br> `(1 to 5) map (_*2)` | infiksni šećer. |
| `def sum(args: Int*) = args.reduceLeft(_+_)` | varirajući broj argumenata (varargs). |
| <span id="packages" class="h2">paketi</span> | |
| `import scala.collection._` | džoker (wildcard) import. |
| `import scala.collection.Vector` <br> `import scala.collection.{Vector, Sequence}` | selektivni import. |
| `import scala.collection.{Vector => Vec28}` | preimenujući import. |
| `import java.util.{Date => _, _}` | import svega iz `java.util` paketa osim `Date`. |
| `package pkg` _na početku fajla_ <br> `package pkg { ... }` | deklaracija paketa. |
| <span id="data_structures" class="h2">strukture podataka</span> | |
| `(1,2,3)` | torka (tuple) literal (`Tuple3`). |
| `var (x,y,z) = (1,2,3)` | destrukturirajuće vezivanje: otpakivanje torke podudaranjem uzoraka (pattern matching). |
| <span class="label important">Loše</span>`var x,y,z = (1,2,3)` | skrivena greška: svim varijablama dodijeljena cijela torka. |
| `var xs = List(1,2,3)` | lista (nepromjenjiva). |
| `xs(2)` | indeksiranje zagradama ([slajdovi](http://www.slideshare.net/Odersky/fosdem-2009-1013261/27)). |
| `1 :: List(2,3)` | cons. |
| `1 to 5` _isto kao_ `1 until 6` <br> `1 to 10 by 2` | šećer za raspon (range). |
| `()` _(prazne zagrade)_ | jedina instanca Unit tipa (slično kao u C/Java void). |
| <span id="control_constructs" class="h2">kontrolne strukture</span> | |
| `if (check) happy else sad` | uslov. |
| `if (check) happy` _isto kao_ <br> `if (check) happy else ()` | sintaksni šećer za uslov. |
| `while (x < 5) { println(x); x += 1}` | while petlja. |
| `do { println(x); x += 1} while (x < 5)` | do while petlja. |
| `import scala.util.control.Breaks._`<br>`breakable {`<br>` for (x <- xs) {`<br>` if (Math.random < 0.1) break`<br>` }`<br>`}`| break ([slajdovi](http://www.slideshare.net/Odersky/fosdem-2009-1013261/21)). |
| `for (x <- xs if x%2 == 0) yield x*10` _isto kao_ <br>`xs.filter(_%2 == 0).map(_*10)` | for komprehensija: filter/map. |
| `for ((x,y) <- xs zip ys) yield x*y` _isto kao_ <br>`(xs zip ys) map { case (x,y) => x*y }` | for komprehensija: destrukturirajuće vezivanje. |
| `for (x <- xs; y <- ys) yield x*y` _isto kao_ <br>`xs flatMap {x => ys map {y => x*y}}` | for komprehensija: međuproizvod (vektorski proizvod). |
| `for (x <- xs; y <- ys) {`<br> `println("%d/%d = %.1f".format(x, y, x/y.toFloat))`<br>`}` | for komprehensija: imperativ-asto.<br>[sprintf-stil.](http://java.sun.com/javase/6/docs/api/java/util/Formatter.html#syntax) |
| `for (i <- 1 to 5) {`<br> `println(i)`<br>`}` | for komprehensija: iteracija uključujući gornju granicu. |
| `for (i <- 1 until 5) {`<br> `println(i)`<br>`}` | for komprehensija: iteracija ne uključujući gornju granicu. |
| <span id="pattern_matching" class="h2">podudaranje uzoraka (pattern matching)</span> | |
| <span class="label success">Dobro</span> `(xs zip ys) map { case (x,y) => x*y }`<br> <span class="label important">Loše</span> `(xs zip ys) map( (x,y) => x*y )` | slučaj korištenja u argumentima funkcije. |
| <span class="label important">Loše</span><br>`val v42 = 42`<br>`Some(3) match {`<br>` case Some(v42) => println("42")`<br>` case _ => println("Not 42")`<br>`}` | "v42" interpretira se kao ime koje odgovara bilo kojoj vrijednosti Int, i "42" se prikazuje. |
| <span class="label success">Dobro</span><br>`val v42 = 42`<br>`Some(3) match {`<br>`` case Some(`v42`) => println("42")``<br>`case _ => println("Not 42")`<br>`}` | "\`v42\`" s kosim apostrofima interpretira se kao postojeća val `v42`, i "Not 42" se prikazuje. |
| <span class="label success">Dobro</span><br>`val UppercaseVal = 42`<br>`Some(3) match {`<br>` case Some(UppercaseVal) => println("42")`<br>` case _ => println("Not 42")`<br>`}` | `UppercaseVal` tretira se kao postojeća val, a ne kao nova vrijednost uzorka, zato što počinje velikim slovom. Stoga, vrijednost u `UppercaseVal` se poredi sa `3`, i "Not 42" se prikazuje. |
| <span id="object_orientation" class="h2">objektna orijentisanost</span> | |
| `class C(x: R)` _isto kao_ <br>`class C(private val x: R)`<br>`var c = new C(4)` | parameteri konstruktora - privatni. |
| `class C(val x: R)`<br>`var c = new C(4)`<br>`c.x` | parameteri konstruktora - javni. |
| `class C(var x: R) {`<br>`assert(x > 0, "positive please")`<br>`var y = x`<br>`val readonly = 5`<br>`private var secret = 1`<br>`def this = this(42)`<br>`}`|<br>konstruktor je tijelo klase.<br>deklaracija javnog člana. <br> deklaracija dostupnog ali nepromjenjivog člana<br>deklaracija privatnog člana.<br>alternativni konstruktor.|
| `new{ ... }` | anonimna klasa. |
| `abstract class D { ... }` | definicija apstraktne klase (ne može se kreirati). |
| `class C extends D { ... }` | definicija nasljedne klase. |
| `class D(var x: R)`<br>`class C(x: R) extends D(x)` | nasljeđivanje i parameteri konstruktora (lista želja: automatsko prosljeđivanje parametara...).
| `object O extends D { ... }` | definicija singletona (kao modul). |
| `trait T { ... }`<br>`class C extends T { ... }`<br>`class C extends D with T { ... }` | trejtovi.<br>interfejs-s-implementacijom. Bez parametara konstruktora. [Miksabilan]({{ site.baseurl }}/tutorials/tour/mixin-class-composition.html).
| `trait T1; trait T2`<br>`class C extends T1 with T2`<br>`class C extends D with T1 with T2` | više trejtova. |
| `class C extends D { override def f = ...}` | moraju se deklarisati prebrisane metode. |
| `new java.io.File("f")` | kreiranje objekta. |
| <span class="label important">Loše</span> `new List[Int]`<br> <span class="label success">Dobro</span> `List(1,2,3)` | greška tipa: apstraktni tip. <br> umjesto toga, konvencija: fabrika istoimenog tipa. |
| `classOf[String]` | literal za klasu. |
| `x.isInstanceOf[String]` | provjera tipa (runtime). |
| `x.asInstanceOf[String]` | kastovanje tipa (runtime). |
| `x: String` | askripcija (compile time). |
Loading