前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Scala基础概述

Scala基础概述

作者头像
羊羽shine
发布2019-07-28 14:09:57
4460
发布2019-07-28 14:09:57
举报
文章被收录于专栏:Golang开发Golang开发

官方网站 https://www.scala-lang.org/

image.png

安装开发环境

下载JDK配置JAVA1.8以上开发环境

代码语言:javascript
复制
$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

下载Scala下载地址 https://www.scala-lang.org/download/

image.png

代码语言:javascript
复制
$ scala -version
Scala code runner version 2.12.8 -- Copyright 2002-2018, LAMP/EPFL and Lightbend, Inc.
scala 历史版本

https://github.com/scala/scala/releases

idea开发IDE的安装
  1. 确保安装了 Java 8 JDK (also known as 1.8)
    • Run javac -version on the command line and make sure you seejavac 1.8.___
    • If you don’t have version 1.8 or higher, install the JDK
  2. 下载 IntelliJ Community Edition
  3. 启动 IntelliJ, 下载安装 Scala 插件,安装插件说明 how to install IntelliJ plugins (search for “Scala” in the plugins menu.)

image.png

创建工程HelloWorld
  1. 打开 IntelliJ 然后点击 File => New => Project 2 在左侧菜单栏选择Scala 然后选择右侧选择IDEA

image.png

  1. 创建项目 HelloWorld 4 如果没有安装Scala SDK 可以选在安装SDK 版本
Writing code
  1. On the Project pane on the left, right-click src and select New => Scala class. If you don’t see Scala class, right-click on HelloWorld and click on Add Framework Support…, select Scala and proceed. If you see Error: library is not specified, you can either click download button, or select the library path manually.
  2. Name the class Hello and change the Kind to object.
  3. Change the code in the class to the following:
代码语言:javascript
复制
object Hello extends App {
  println("Hello, World!")
}
REPL(Read Eval Print Loop:交互式解释器)
代码语言:javascript
复制
$ scala
Welcome to Scala 2.12.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_121).
Type in expressions for evaluation. Or try :help.
scala> var x = 1
x: Int = 1
scala> :q
Maven创建项目

选择org.scals-tools.archetypes:scala-archetype-simple

image.png

代码语言:javascript
复制
<dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala.version}</version>
 </dependency>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019.07.27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装开发环境
  • scala 历史版本
  • idea开发IDE的安装
    • 创建工程HelloWorld
      • Writing code
      • REPL(Read Eval Print Loop:交互式解释器)
      • Maven创建项目
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档