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
#!/usr/bin/env io | |
Vehicle := Object clone | |
Vehicle desc := "Moving Object" | |
Car := Vehicle clone | |
Car drive := method ("Vrooom..." println) | |
ferrari := Car clone | |
Car drive | |
Car slotNames println |
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
module ActsAsCsv | |
def self.included(base) | |
base.extend ClassMethods | |
base.act_as_csv | |
end | |
module ClassMethods | |
def act_as_csv | |
include InstanceMethods |
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
Print array 4 elements each time | |
[*(1..16)].each { |v| v%4==0? p(v) : print("#{v},")} |
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
#1. Print Hello World | |
puts "Hello World." | |
#2. Index of "Ruby" | |
puts "Hello Ruby".index("Ruby") | |
#3. Name 10 times | |
puts "Srikanth#{$/}" * 10 | |
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
DateFormat indiaDtFmt = new SimpleDateFormat("dd/MM/yyyy HH'h'mm"); | |
DateFormat gmtDtFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
indiaDtFmt.setTimeZone(TimeZone.getTimeZone("Asia/Calcutta")); | |
gmtDtFmt.setTimeZone(TimeZone.getTimeZone("GMT")); | |
Date worldWarIIDate = indiaDtFmt.parse("02/02/1944 06h30"); | |
Date nonWorldWarIIDate = indiaDtFmt.parse("02/02/2006 06h30"); | |
System.err.println(gmtDtFmt.format(worldWarIIDate) +" GMT"); |
NewerOlder