Created
October 17, 2010 12:29
-
-
Save nurkiewicz/630801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//$ javap -c Book | |
//... | |
public Book(java.lang.String, java.lang.String, int); | |
Code: | |
0: aload_0 | |
1: aload_1 | |
2: putfield #28; //Field author:Ljava/lang/String; | |
5: aload_0 | |
6: aload_2 | |
7: putfield #35; //Field title:Ljava/lang/String; | |
10: aload_0 | |
11: iload_3 | |
12: putfield #38; //Field year:I | |
15: aload_0 | |
16: invokespecial #49; //Method java/lang/Object."<init>":()V | |
19: return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//$ javap -private Book | |
Compiled from "Book.scala" | |
public class Book extends java.lang.Object implements scala.ScalaObject{ | |
private final java.lang.String author; | |
private final java.lang.String title; | |
private final int year; | |
public java.lang.String toString(); | |
public Book(java.lang.String, java.lang.String, int); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.lang.builder._ | |
class Book(author: String, title: String, year: Int) { | |
override def toString = | |
new ToStringBuilder() | |
.append("author", author) | |
.append("title", title) | |
.append("year", year) | |
.toString() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def capitalizeAfterHash(list: List[Char]): List[Char] = | |
list match { | |
case '#' :: rest => | |
rest.map(_.toUpper) | |
case _ :: rest => | |
capitalizeAfterHash(rest) | |
case Nil => | |
Nil | |
} | |
println(capitalizeAfterHash('a' :: 'b' :: '#' :: 'c' :: 'd' :: Nil)) | |
println(capitalizeAfterHash('#' :: 'c' :: 'd' :: Nil)) | |
println(capitalizeAfterHash('a' :: 'b' :: Nil)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment