Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Tale of a Happy Programmer

A Tale of a Happy Programmer

Ruby programmers are happy programmers

Nugroho Herucahyono

September 26, 2013
Tweet

More Decks by Nugroho Herucahyono

Other Decks in Programming

Transcript

  1. Who's talking? Nugroho Herucahyono programming since 12 years old ex

    java programmer rubyist since 2006 twitter: @xinuc github: @xinuc
  2. Disclaimer • This is my first jakarta.rb • Not a

    technical talk • I'm really bad at public speaking • So, please bear with me
  3. import java.io.File; import java.io.InputStream; // ... declare class, etc., then

    ... public byte[] justReadMeAFilePlease() { try { file = new File("my-file.txt"); fis = new FileInputStream(file); byte[] b = new byte[(int) file.length()]; fis.read(b); return b; } catch (Exception e) { e.printStackTrace(); } }
  4. import java.util.Arrays; import java.util.Comparator; import java.util.Collections; import java.util.List; public class

    SortList { public static void main (String[] args){ List<String> names = Arrays.asList("Nugroho", "Xinuc", "Herucahyono"); Collections.sort(names, new Comparator<String>(){ public int compare(String first, String second){ return (first.length() > second.length()) ? 1 : -1; } }); StringBuffer buf = new StringBuffer(""); String sep = ""; for(String name : names){ buf.append(sep); buf.append(name); sep = ", "; } System.out.println(buf.toString()); } } •