2013-07-08 2 views
5

나는 스칼라에서 파이썬에 익숙하지만 멍청한 사람이다. 필자는 스칼라에 더러운 실험 코드를 작성하려고합니다. 스칼라가 파이썬에서 help()과 같은 함수를 가지고 있다면 정말 편리 할 거라고 생각했습니다. 예를 들어, Scala에 내장 된 메서드를보고 싶다면 Arrayhelp(Array)과 같은 것을 입력하고 싶습니다. help(list)을 Python으로 입력하면됩니다. 스칼라에는 그런 것이 있습니까?스칼라와 파이썬 도움말()

+1

탭 완료시 : SBT console 명령은 클래스 경로

예에 프로젝트 클래스와 의존성 스칼라 REPL을 시작? – sschaef

답변

4

하나는 내장되어 있지 않지만 동일한 정보를 찾으려면 Scaladocs을 사용해야합니다.

짧은 설명과 함께 자동 완성 기능이있는 이클립스를 사용하지 않는 한. 예를 들어, 'array'를 입력하면 배열에 대한 모든 명령을 제공합니다.

+0

감사! 나는 Scaladocs를 사용하는 방법을 아직 모르지만 알아낼 것이다. – Ray

+0

내가 일반적으로하는 것은 단지 Google의 메서드와 scaladocs뿐입니다. 첫 번째 커플 링크 중 하나가 당신이 찾고있는 것입니다. – brebs

1

마찬가지로 IDEA는 Scala 및 Java (-Doc) JAR 및 소스 코드 문서 주석에 사용할 수있는 "빠른 문서 검색"명령을 가지고 있습니다.

3

필자는 탭 완성이 파이썬의 도움에 가장 가까운 것이라고 생각합니다.

날짜가 있지만 여전히 관련이있는 Scala 문서 사용시 @dcsobral의 post과 Haskell의 Hoogle과 유사한 Scalex이 있습니다.

이것은 ObjectArray의 탭 완성입니다.

scala> Array. 
apply     asInstanceOf   canBuildFrom   concat     copy     
empty     emptyBooleanArray  emptyByteArray   emptyCharArray   emptyDoubleArray  
emptyFloatArray  emptyIntArray   emptyLongArray   emptyObjectArray  emptyShortArray   
fallbackCanBuildFrom fill     isInstanceOf   iterate    newBuilder    
ofDim     range     tabulate    toString    unapplySeq 

이것은 Array 클래스의 메소드입니다. 방법에 번 탭 완료시 조금 어려운이 메소드 서명을 표시하지만이 a.

scala> val a = Array(1,2,3) 
a: Array[Int] = Array(1, 2, 3) 

scala> a. 
apply   asInstanceOf clone   isInstanceOf length   toString  update 

후 값 회원을 표시하지 않는 이유를 확실하지. 여기가 scaladoc을 찾는위한 sbt 플러그인은 Array.fill

def fill[T](n1: Int, n2: Int)(elem: => T)(implicit evidence$10: reflect.ClassTag[T]): Array[Array[T]]             
def fill[T](n1: Int, n2: Int, n3: Int)(elem: => T)(implicit evidence$11: reflect.ClassTag[T]): Array[Array[Array[T]]]         
def fill[T](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => T)(implicit evidence$12: reflect.ClassTag[T]): Array[Array[Array[Array[T]]]]     
def fill[T](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => T)(implicit evidence$13: reflect.ClassTag[T]): Array[Array[Array[Array[Array[T]]]]] 
def fill[T](n: Int)(elem: => T)(implicit evidence$9: reflect.ClassTag[T]): Array[T] 
+0

탭 완료는 implicits를 통해 추가 된 멤버를 수행하지 않습니다. 그러나 탭핑은 나를 위해 scaladoc보다 쉽습니다 (반사 API가 마음에 듭니다). –

+0

흠 탭 완성은 파이썬의'help()'보다 덜 우아 해 보입니다 만, 그 목적을 달성 한 것 같습니다. 고맙습니다! – Ray

1

sbt-man을 위해이다. REPL에서

man Traversable /: 
[man] scala.collection.Traversable 
[man] def /:[B](z: B)(op: (B ⇒ A ⇒ B)): B 
[man] Applies a binary operator to a start value and all elements of this 
collection, going left to right. Note: /: is alternate syntax for foldLeft; 
z /: xs is the same as xs foldLeft z. Note: will not terminate for infinite- 
sized collections. Note: might return different results for different runs, 
unless the underlying collection type is ordered. or the operator is 
associative and commutative.