DOC PREVIEW
TRINITY CSCI 1320 - Scala Expressions and Types

This preview shows page 1-2-3-4-5 out of 14 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Scala Expressions and Types 8 31 2011 Opening Discussion Minute essay comments Using cp and mv Editing a Word Notepad document with vi Classes methods in Scala Differences between less more and cat Access from a Windows machine vi stands for visual editor and is just a text editor It can take a while to get comfortable Practice All of our Linux commands will work on a Mac Vi can edit existing files or make new ones vi The vi editor is standard on Linux which is one reason we like to use it It is also good for programming Has modes Start in command mode You type in an edit mode i insert I insert at beginning of line a append A append at end of line R replace characters Other Commands x delete characters dd delete lines yy yank copy lines p or P paste before or after r replace a single character J join lines and n search for something and next cw change a word repeat last command u and Crtl r Undo and redo Scala Script First Program Let s go into your course and use vi to write our first Scala program then run it The standard first program is Hello World and I don t want to break with tradition Scala REPL If you just type scala and don t provide a file name to run it will drop you into the REPL Read Evaluate Print Loop Here you can enter individual commands and have them run It is great for testing things out and getting to learn the language Key Terms Token A set of characters that has meaning to the language Statement A set of tokens that give a complete instruction Expression Tokens put together that produce a value Type All values have types A type is a set of values and the operations allowed on them Literal A token that represents a value Numeric String Character Boolean Statements and Semicolon Inference In Scala as with most programming languages programs are made by putting together statements In Scala any expression is a valid statement as are a few other constructs Statements end with semicolons but they will be inferred at the end of a line if they make sense so you rarely type them Operators We can build longer expressions by putting literals together with operators Let s start off by playing with some of the numeric operations you are probably familiar with You can get the remainder after division with Objects An object is defined to be information along with the things you can do with that information The information in an object is called the properties The actions are called methods In Scala even things like Int are objects and have methods on them Methods The normal way to call a method in Scala and most other object oriented languages is to put a period after the object and follow it with the method name The REPL will do tab completion and list methods for you Let s look at the methods on some basic types and try calling them Arguments Some methods need additional information to work To give this to the method we pass in arguments Arguments are put in parentheses and separated by commas if there is more than one The parentheses are generally optional in Scala if there is no argument Operator Syntax All the operators in Scala are really just methods Scala allows any method with zero or one arguments to be called with an operator syntax That means you leave off the dot and the parentheses If a method takes no arguments you can call it without the dot Minute Essay What in today s lectures was confusing Was there anything that surprised you Remember that we will do the first IcP on Friday


View Full Document

TRINITY CSCI 1320 - Scala Expressions and Types

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Scala Expressions and Types
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Scala Expressions and Types and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Scala Expressions and Types and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?