I have defined a function named ti but after compilation it shows a deprecation warning. I did the same in Eclipse. The code works fine but it shows a warning.
scala> def ti(chars:List[Char],a:List[(Char,Integer)]):List[(Char,Integer)] = {
| if(chars.length!=0) {
| var j = 1
| var c = chars.head
| for(i<-chars.tail) {
| if(c==i) j=j+1
| }
| a::List((c,j))
| ti(chars.tail,a)
| }
| else a
| }
warning: there were 3 deprecation warnings; re-run with -deprecation for details ti: (chars: List[Char], a: List[(Char, Integer)])List[(Char, Integer)]
What is the reason for this?
If it tells you to re-run with -deprecation, you should do that:
k@k:~$ scala -deprecation
Welcome to Scala version 2.9.1 (OpenJDK 64-Bit Server VM, Java 1.6.0_24).
Type in expressions to have them evaluated.
Type :help for more information.
scala> def ti(chars:List[Char],a:List[(Char,Integer)]):List[(Char,Integer)]=
| { if(chars.length!=0)
| {
| var j=1
| var c=chars.head
| for(i<-chars.tail)
| {
| if(c==i) j=j+1
| }
| a::List((c,j))
| ti(chars.tail,a)
| }
| else a
| }
Then you get your warnings:
<console>:7: warning: type Integer is deprecated: use java.lang.Integer instead
def ti(chars:List[Char],a:List[(Char,Integer)]):List[(Char,Integer)]=
^
<console>:7: warning: type Integer is deprecated: use java.lang.Integer instead
def ti(chars:List[Char],a:List[(Char,Integer)]):List[(Char,Integer)]=
^
<console>:16: warning: type Integer is deprecated: use java.lang.Integer instead
a::List((c,j))
^
Here the issue is that you should use java.lang.Integer or just Int if you don't need interoperability with Java. So you either import java.lang.Integer or change Integer to Int.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With