我目前正在教同事.Net,他问我一个困扰我的问题.
我们为什么要申报?
如果var是隐式类型,为什么我们甚至要声明?
Animal animal = new Animal();
Run Code Online (Sandbox Code Playgroud)
变
var animal = new Animal();
Run Code Online (Sandbox Code Playgroud)
可能成为
animal = new Animal();
Run Code Online (Sandbox Code Playgroud)
隐式类型仍然意味着这是一个静态类型的变量.
如果为变量分配了两种不同的类型,如果它们不共享基类(除了对象),则可能是编译器错误.
是否有技术原因无法完成或风格上我们喜欢有没有
Maven 新手,可能是新手错误。
我正在做 jenkins 课程的复数介绍。我们http://github.com/g0t4/jenkins2-course-spring-boot
在其子目录中克隆 git 存储库,其中jenkins2-course-spring-boot\spring-boot-samples\spring-boot-sample-atmosphere
有以下 pom.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<!-- Your own application should inherit from spring-boot-starter-parent -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-samples</artifactId>
<version>1.4.0.BUILD-SNAPSHOT</version>
</parent>
<artifactId>spring-boot-sample-atmosphere</artifactId>
<name>Spring Boot Atmosphere Sample</name>
<description>Spring Boot Atmosphere Sample</description>
<url>http://projects.spring.io/spring-boot/</url>
<organization>
<name>Pivotal Software, Inc.</name>
<url>http://www.spring.io</url>
</organization>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>atmosphere-javascript</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> …
Run Code Online (Sandbox Code Playgroud) 位数组从右到左,例如 [0,1,0,1] = 10 可以通过以下方式读取:
binToInt = foldr (\x xs -> x + 2 * xs) 0
Run Code Online (Sandbox Code Playgroud)
我想从左到右阅读,例如 [1,0,1,0] = 10
我认为这会起作用:
binToInt' = foldr (\x xs -> (x * ((^) 2 (length xs)) + xs) 0
Run Code Online (Sandbox Code Playgroud)
但是我收到错误:
Couldn't match type `t0 a0' with `Int'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
(作为解决方法,我正在反转 binToInt 的结果)
我在哪个文件中找到( - >)的定义
我的假设是,这是在GHC.something的某处定义的,但搜索起来很棘手.