Sunday, 21 June 2015

Coffee With Scala

What is difference between def and val ?
-- Def evaluate every time we access them but val only evaluate when object referenced first time.

Details on

  1. val
  2. lazy val
  3. def

Following example is best way to understand above three.

scala> class X { val x = { Thread.sleep(2000); 15 } }
defined class X

scala> class Y { lazy val y = { Thread.sleep(2000); 13 } }
defined class Y

scala> new X
res5: X = X@262505b7 // we have to wait two seconds to the result

scala> new Y
res6: Y = Y@1555bd22 // this appears immediately

Thursday, 18 June 2015

Compression and Decompression (tar,rar,zip,gzip)

About  tar, rar, zip, gzip

tar puts multiple files into a single(tar) file. [On unix or Unix like system]
rar    puts multiple files into a single(tar) file. [On Windows]
gzip compresses one file (only).  [On unix or Unix like system]
zip compresses one file (only).  [On windows]

We can first tar the all file into single tar file then compressed it using gzip and file has extension like  name.tar.gzip

Thursday, 11 June 2015

JavaScript Debugging and Testing

You can debug java script  by using two ways 

  • By logging into DevTool console using console.log()
  • Using debugger key word
<script>
     callDebugSentence();
    function callDebugSentence(){
             debugger;
            console.log("After debugger sentence");
     }
</script>